Skip to content

Commit

Permalink
Try to use UNITY_BUILD
Browse files Browse the repository at this point in the history
With CMAKE_UNITY_BUILD there are build error with ftxui!

Quickfix: don't build ftxui_sample if CMAKE_UNITY_BUILD is set.
  • Loading branch information
ClausKlein committed Aug 27, 2023
1 parent d19d892 commit 5549a82
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
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)
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

0 comments on commit 5549a82

Please sign in to comment.