Skip to content
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

Try to use UNITY_BUILD #63

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.21)
cmake_minimum_required(VERSION 3.21...3.27)

# This template attempts to be "fetch_content"-able
# so that it works well with tools like CPM or other
Expand Down
9 changes: 8 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"Darwin"
]
},
"cacheVariables": {
"CMAKE_UNITY_BUILD": true
},
"vendor": {
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
Expand Down Expand Up @@ -142,6 +145,8 @@
"description": "Target Unix-like OS with the gcc compiler, debug build type",
"inherits": "conf-unixlike-common",
"cacheVariables": {
"myproject_ENABLE_COVERAGE": false,
"CMAKE_SKIP_INSTALL_RULES": true,
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_BUILD_TYPE": "Debug"
Expand All @@ -164,6 +169,8 @@
"description": "Target Unix-like OS with the clang compiler, debug build type",
"inherits": "conf-unixlike-common",
"cacheVariables": {
"myproject_ENABLE_COVERAGE": false,
"CMAKE_SKIP_INSTALL_RULES": true,
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_BUILD_TYPE": "Debug"
Expand Down Expand Up @@ -251,4 +258,4 @@
"configurePreset": "unixlike-clang-release"
}
]
}
}
6 changes: 3 additions & 3 deletions ProjectOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ macro(myproject_setup_options)
option(myproject_ENABLE_SANITIZER_UNDEFINED "Enable undefined sanitizer" ${SUPPORTS_UBSAN})
option(myproject_ENABLE_SANITIZER_THREAD "Enable thread sanitizer" OFF)
option(myproject_ENABLE_SANITIZER_MEMORY "Enable memory sanitizer" OFF)
option(myproject_ENABLE_UNITY_BUILD "Enable unity builds" OFF)
option(myproject_ENABLE_CLANG_TIDY "Enable clang-tidy" ON)
option(myproject_ENABLE_CPPCHECK "Enable cpp-check analysis" ON)
option(myproject_ENABLE_UNITY_BUILD "Enable unity builds" ON)
option(myproject_ENABLE_CLANG_TIDY "Enable clang-tidy" OFF)
option(myproject_ENABLE_CPPCHECK "Enable cpp-check analysis" OFF)
Comment on lines +56 to +58
Copy link
Contributor Author

@ClausKlein ClausKlein Aug 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO: developers shouldn't wast its time.

run-clang-tidy -p out/builddir is easy to use

Only on CI clang-tidy must at least run one times.

option(myproject_ENABLE_PCH "Enable precompiled headers" OFF)
option(myproject_ENABLE_CACHE "Enable ccache" ON)
endif()
Expand Down
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
add_subdirectory(sample_library)
add_subdirectory(ftxui_sample)
if(NOT CMAKE_UNITY_BUILD)
add_subdirectory(ftxui_sample)
endif()
20 changes: 11 additions & 9 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15...3.23)
cmake_minimum_required(VERSION 3.21...3.27)

project(CmakeConfigPackageTests LANGUAGES CXX)

Expand All @@ -19,15 +19,17 @@ endif()

include(${Catch2_SOURCE_DIR}/extras/Catch.cmake)

# Provide a simple smoke test to make sure that the CLI works and can display a --help message
add_test(NAME cli.has_help COMMAND intro --help)
if(TARGET intro)
# Provide a simple smoke test to make sure that the CLI works and can display a --help message
add_test(NAME cli.has_help COMMAND intro --help)

# Provide a test to verify that the version being reported from the application
# matches the version given to CMake. This will be important once you package
# your program. Real world shows that this is the kind of simple mistake that is easy
# to make, but also easy to test for.
add_test(NAME cli.version_matches COMMAND intro --version)
set_tests_properties(cli.version_matches PROPERTIES PASS_REGULAR_EXPRESSION "${PROJECT_VERSION}")
# Provide a test to verify that the version being reported from the application
# matches the version given to CMake. This will be important once you package
# your program. Real world shows that this is the kind of simple mistake that is easy
# to make, but also easy to test for.
add_test(NAME cli.version_matches COMMAND intro --version)
set_tests_properties(cli.version_matches PROPERTIES PASS_REGULAR_EXPRESSION "${PROJECT_VERSION}")
endif()

add_executable(tests tests.cpp)
target_link_libraries(
Expand Down
Loading