Skip to content

Commit 5549a82

Browse files
committed
Try to use UNITY_BUILD
With CMAKE_UNITY_BUILD there are build error with ftxui! Quickfix: don't build ftxui_sample if CMAKE_UNITY_BUILD is set.
1 parent d19d892 commit 5549a82

File tree

5 files changed

+26
-15
lines changed

5 files changed

+26
-15
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.21)
1+
cmake_minimum_required(VERSION 3.21...3.27)
22

33
# This template attempts to be "fetch_content"-able
44
# so that it works well with tools like CPM or other

CMakePresets.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
"Darwin"
5151
]
5252
},
53+
"cacheVariables": {
54+
"CMAKE_UNITY_BUILD": true
55+
},
5356
"vendor": {
5457
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
5558
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
@@ -142,6 +145,8 @@
142145
"description": "Target Unix-like OS with the gcc compiler, debug build type",
143146
"inherits": "conf-unixlike-common",
144147
"cacheVariables": {
148+
"myproject_ENABLE_COVERAGE": false,
149+
"CMAKE_SKIP_INSTALL_RULES": true,
145150
"CMAKE_C_COMPILER": "gcc",
146151
"CMAKE_CXX_COMPILER": "g++",
147152
"CMAKE_BUILD_TYPE": "Debug"
@@ -164,6 +169,8 @@
164169
"description": "Target Unix-like OS with the clang compiler, debug build type",
165170
"inherits": "conf-unixlike-common",
166171
"cacheVariables": {
172+
"myproject_ENABLE_COVERAGE": false,
173+
"CMAKE_SKIP_INSTALL_RULES": true,
167174
"CMAKE_C_COMPILER": "clang",
168175
"CMAKE_CXX_COMPILER": "clang++",
169176
"CMAKE_BUILD_TYPE": "Debug"
@@ -251,4 +258,4 @@
251258
"configurePreset": "unixlike-clang-release"
252259
}
253260
]
254-
}
261+
}

ProjectOptions.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ macro(myproject_setup_options)
5353
option(myproject_ENABLE_SANITIZER_UNDEFINED "Enable undefined sanitizer" ${SUPPORTS_UBSAN})
5454
option(myproject_ENABLE_SANITIZER_THREAD "Enable thread sanitizer" OFF)
5555
option(myproject_ENABLE_SANITIZER_MEMORY "Enable memory sanitizer" OFF)
56-
option(myproject_ENABLE_UNITY_BUILD "Enable unity builds" OFF)
57-
option(myproject_ENABLE_CLANG_TIDY "Enable clang-tidy" ON)
58-
option(myproject_ENABLE_CPPCHECK "Enable cpp-check analysis" ON)
56+
option(myproject_ENABLE_UNITY_BUILD "Enable unity builds" ON)
57+
option(myproject_ENABLE_CLANG_TIDY "Enable clang-tidy" OFF)
58+
option(myproject_ENABLE_CPPCHECK "Enable cpp-check analysis" OFF)
5959
option(myproject_ENABLE_PCH "Enable precompiled headers" OFF)
6060
option(myproject_ENABLE_CACHE "Enable ccache" ON)
6161
endif()

src/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
add_subdirectory(sample_library)
2-
add_subdirectory(ftxui_sample)
2+
if(NOT CMAKE_UNITY_BUILD)
3+
add_subdirectory(ftxui_sample)
4+
endif()

test/CMakeLists.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.15...3.23)
1+
cmake_minimum_required(VERSION 3.21...3.27)
22

33
project(CmakeConfigPackageTests LANGUAGES CXX)
44

@@ -19,15 +19,17 @@ endif()
1919

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

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

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

3234
add_executable(tests tests.cpp)
3335
target_link_libraries(

0 commit comments

Comments
 (0)