-
Notifications
You must be signed in to change notification settings - Fork 26
Update CMake config #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yaigorian
wants to merge
22
commits into
DafeCpp:main
Choose a base branch
from
yaigorian:feature
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
30660dd
done task_01
ed6b859
done task_02
d5baaa3
done task_07
4e146d7
done task_03
9ff5b08
done task_04
3aa1e46
done task_05
641adfd
done task_06
29e5692
done task_08
b7de98e
done task_09
bc8f6dd
done task_10
0a80cad
done task_11
8cc8d58
done task_12
b2bc0e4
done task_13
e376c85
done task_14
8076225
ci: rerun
409e14a
Fix task_07 CI build and run clang-format
aaa53fc
update version CMake
66da02a
base update
37fa3df
update doc
79df745
Revert "update doc"
abc56b8
fix some bugs in cmake works
7fd6c8f
Simplify cmake command in tests workflow
yaigorian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,54 @@ | ||
| cmake_minimum_required(VERSION 3.10) | ||
| cmake_minimum_required(VERSION 3.16) | ||
|
|
||
| project(homeworks) | ||
| project(homeworks LANGUAGES CXX) | ||
|
|
||
| add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib) | ||
| option(BUILD_SANDBOX "Build sandbox targets" OFF) | ||
| option(BUILD_ADDITIONAL_TASKS "Build additional tasks" OFF) | ||
| set(BUILD_TASK "" CACHE STRING "Build only one task, for example task_07") | ||
|
|
||
| add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/sandbox) | ||
| set(HOMEWORK_TASKS | ||
| task_01 | ||
| task_02 | ||
| task_03 | ||
| task_04 | ||
| task_05 | ||
| task_06 | ||
| task_07 | ||
| task_08 | ||
| task_09 | ||
| task_10 | ||
| task_11 | ||
| task_12 | ||
| task_13 | ||
| task_14) | ||
|
|
||
| add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/additional_tasks) | ||
| list(FIND HOMEWORK_TASKS "${BUILD_TASK}" build_task_index) | ||
|
|
||
| file(GLOB_RECURSE tasks_dirs LIST_DIRECTORIES true ".") | ||
| if(BUILD_TASK AND build_task_index EQUAL -1) | ||
| message(FATAL_ERROR "Unknown BUILD_TASK='${BUILD_TASK}'. Expected one of: ${HOMEWORK_TASKS}") | ||
| endif() | ||
|
|
||
| foreach(dir ${tasks_dirs}) | ||
| IF(IS_DIRECTORY ${dir}) | ||
| IF(${dir} MATCHES "task_[0-9][0-9]$" AND NOT ${dir} MATCHES "build") | ||
| add_subdirectory(${dir}) | ||
| ENDIF() | ||
| ELSE() | ||
| CONTINUE() | ||
| ENDIF() | ||
| endforeach() | ||
| add_subdirectory(lib) | ||
|
|
||
| include(CTest) | ||
|
|
||
| if(BUILD_TESTING) | ||
| find_package(GTest REQUIRED) | ||
| include(GoogleTest) | ||
| endif() | ||
|
|
||
| if(BUILD_TASK) | ||
| add_subdirectory(${BUILD_TASK}) | ||
| else() | ||
| foreach(task IN LISTS HOMEWORK_TASKS) | ||
| add_subdirectory(${task}) | ||
| endforeach() | ||
|
|
||
| if(BUILD_SANDBOX) | ||
| add_subdirectory(sandbox) | ||
| endif() | ||
|
|
||
| if(BUILD_ADDITIONAL_TASKS) | ||
| add_subdirectory(additional_tasks) | ||
| endif() | ||
| endif() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| function(add_homework_task) | ||
| set(options) | ||
| set(one_value_args NAME) | ||
| set(multi_value_args SOURCES TEST_SOURCES INCLUDE_DIRS) | ||
| cmake_parse_arguments(TASK "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN}) | ||
|
|
||
| if(NOT TASK_NAME) | ||
| message(FATAL_ERROR "add_homework_task requires NAME") | ||
| endif() | ||
|
|
||
| if(NOT TASK_SOURCES) | ||
| message(FATAL_ERROR "add_homework_task(${TASK_NAME}) requires SOURCES") | ||
| endif() | ||
|
|
||
| add_executable(${TASK_NAME} ${TASK_SOURCES}) | ||
| target_compile_features(${TASK_NAME} PRIVATE cxx_std_23) | ||
| target_include_directories( | ||
| ${TASK_NAME} | ||
| PRIVATE | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/src" | ||
| ${TASK_INCLUDE_DIRS} | ||
| ) | ||
| target_link_libraries(${TASK_NAME} PRIVATE Utils) | ||
|
|
||
| if(BUILD_TESTING AND TASK_TEST_SOURCES) | ||
| add_executable(${TASK_NAME}_tests ${TASK_TEST_SOURCES}) | ||
| target_compile_features(${TASK_NAME}_tests PRIVATE cxx_std_23) | ||
| target_include_directories( | ||
| ${TASK_NAME}_tests | ||
| PRIVATE | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/src" | ||
| ${TASK_INCLUDE_DIRS} | ||
| ) | ||
| target_link_libraries(${TASK_NAME}_tests PRIVATE GTest::gtest_main Utils) | ||
| gtest_discover_tests(${TASK_NAME}_tests) | ||
| endif() | ||
| endfunction() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,6 @@ | ||
| cmake_minimum_required(VERSION 3.10) | ||
| project(Utils) | ||
| add_library(Utils | ||
| src/util.cpp | ||
| ) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 23) | ||
|
|
||
| file(GLOB_RECURSE lib_source_list "src/*.cpp" "src/*.hpp") | ||
|
|
||
| add_library(${PROJECT_NAME} ${lib_source_list}) | ||
|
|
||
| target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) | ||
| target_compile_features(Utils PUBLIC cxx_std_23) | ||
| target_include_directories(Utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,11 @@ | ||
|
|
||
| cmake_minimum_required(VERSION 3.10) | ||
|
|
||
| get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) | ||
| string(REPLACE " " "_" PROJECT_NAME ${PROJECT_NAME}) | ||
| project(${PROJECT_NAME} C CXX) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 23) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
|
||
| file(GLOB_RECURSE source_list "src/*.cpp" "src/*.hpp") | ||
| file(GLOB_RECURSE main_source_list "src/main.cpp") | ||
| file(GLOB_RECURSE test_source_list "src/*.cpp") | ||
| file(GLOB_RECURSE test_list "src/*test.cpp") | ||
|
|
||
| list(REMOVE_ITEM test_source_list ${main_source_list}) | ||
| list(REMOVE_ITEM source_list ${test_list}) | ||
|
|
||
| include_directories(${PROJECT_NAME} PUBLIC src) | ||
|
|
||
| add_executable(${PROJECT_NAME} ${source_list}) | ||
|
|
||
| # Locate GTest | ||
| enable_testing() | ||
| find_package(GTest REQUIRED) | ||
|
|
||
| include_directories(${GTEST_INCLUDE_DIRS}) | ||
|
|
||
| target_link_libraries(${PROJECT_NAME} PUBLIC Utils) | ||
|
|
||
| # Link runTests with what we want to test and the GTest and pthread library | ||
| add_executable(${PROJECT_NAME}_tests ${test_source_list}) | ||
| target_link_libraries( | ||
| ${PROJECT_NAME}_tests | ||
| GTest::gtest_main | ||
| Utils | ||
| include(${CMAKE_SOURCE_DIR}/cmake/AddHomeworkTask.cmake) | ||
|
|
||
| # If you add extra implementation files in src/, list them in SOURCES and | ||
| # TEST_SOURCES explicitly. CMake will not pick new .cpp files automatically. | ||
| add_homework_task( | ||
| NAME task_01 | ||
| SOURCES | ||
| src/main.cpp | ||
| TEST_SOURCES | ||
| src/test.cpp | ||
| ) | ||
|
|
||
| include(GoogleTest) | ||
| gtest_discover_tests(${PROJECT_NAME}_tests) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,11 @@ | ||
|
|
||
| cmake_minimum_required(VERSION 3.10) | ||
|
|
||
| get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) | ||
| string(REPLACE " " "_" PROJECT_NAME ${PROJECT_NAME}) | ||
| project(${PROJECT_NAME} C CXX) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 23) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
|
||
| file(GLOB_RECURSE source_list "src/*.cpp" "src/*.hpp") | ||
| file(GLOB_RECURSE main_source_list "src/main.cpp") | ||
| file(GLOB_RECURSE test_source_list "src/*.cpp") | ||
| file(GLOB_RECURSE test_list "src/*test.cpp") | ||
|
|
||
| list(REMOVE_ITEM test_source_list ${main_source_list}) | ||
| list(REMOVE_ITEM source_list ${test_list}) | ||
|
|
||
| include_directories(${PROJECT_NAME} PUBLIC src) | ||
|
|
||
| add_executable(${PROJECT_NAME} ${source_list}) | ||
|
|
||
| # Locate GTest | ||
| enable_testing() | ||
| find_package(GTest REQUIRED) | ||
|
|
||
| include_directories(${GTEST_INCLUDE_DIRS}) | ||
|
|
||
| target_link_libraries(${PROJECT_NAME} PUBLIC Utils) | ||
|
|
||
| # Link runTests with what we want to test and the GTest and pthread library | ||
| add_executable(${PROJECT_NAME}_tests ${test_source_list}) | ||
| target_link_libraries( | ||
| ${PROJECT_NAME}_tests | ||
| GTest::gtest_main | ||
| Utils | ||
| include(${CMAKE_SOURCE_DIR}/cmake/AddHomeworkTask.cmake) | ||
|
|
||
| # If you add extra implementation files in src/, list them in SOURCES and | ||
| # TEST_SOURCES explicitly. CMake will not pick new .cpp files automatically. | ||
| add_homework_task( | ||
| NAME task_02 | ||
| SOURCES | ||
| src/main.cpp | ||
| TEST_SOURCES | ||
| src/test.cpp | ||
| ) | ||
|
|
||
| include(GoogleTest) | ||
| gtest_discover_tests(${PROJECT_NAME}_tests) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,11 @@ | ||
|
|
||
| cmake_minimum_required(VERSION 3.10) | ||
|
|
||
| get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) | ||
| string(REPLACE " " "_" PROJECT_NAME ${PROJECT_NAME}) | ||
| project(${PROJECT_NAME} C CXX) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 23) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
|
||
| file(GLOB_RECURSE source_list "src/*.cpp" "src/*.hpp") | ||
| file(GLOB_RECURSE main_source_list "src/main.cpp") | ||
| file(GLOB_RECURSE test_source_list "src/*.cpp") | ||
| file(GLOB_RECURSE test_list "src/*test.cpp") | ||
|
|
||
| list(REMOVE_ITEM test_source_list ${main_source_list}) | ||
| list(REMOVE_ITEM source_list ${test_list}) | ||
|
|
||
| include_directories(${PROJECT_NAME} PUBLIC src) | ||
|
|
||
| add_executable(${PROJECT_NAME} ${source_list}) | ||
|
|
||
| # Locate GTest | ||
| enable_testing() | ||
| find_package(GTest REQUIRED) | ||
|
|
||
| include_directories(${GTEST_INCLUDE_DIRS}) | ||
|
|
||
| target_link_libraries(${PROJECT_NAME} PUBLIC Utils) | ||
|
|
||
| # Link runTests with what we want to test and the GTest and pthread library | ||
| add_executable(${PROJECT_NAME}_tests ${test_source_list}) | ||
| target_link_libraries( | ||
| ${PROJECT_NAME}_tests | ||
| GTest::gtest_main | ||
| Utils | ||
| include(${CMAKE_SOURCE_DIR}/cmake/AddHomeworkTask.cmake) | ||
|
|
||
| # If you add extra implementation files in src/, list them in SOURCES and | ||
| # TEST_SOURCES explicitly. CMake will not pick new .cpp files automatically. | ||
| add_homework_task( | ||
| NAME task_03 | ||
| SOURCES | ||
| src/main.cpp | ||
| TEST_SOURCES | ||
| src/test.cpp | ||
| ) | ||
|
|
||
| include(GoogleTest) | ||
| gtest_discover_tests(${PROJECT_NAME}_tests) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тесты собираются только если передан флаг
-DBUILD_TESTING=ON. Нужно убедиться, что GitHub Actions workflow явно передаёт этот флаг при вызове cmake, иначе тесты не будут собираться и CI будет «зелёным» без реальной проверкиThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавил флаг
-DBUILD_TESTING=ONв шагrun cmakeв.github/workflows/tests.yaml, теперь тесты собираются и CI их гарантировано проверяет.