Skip to content

Commit 46995f6

Browse files
authored
Avoid to export Debug flags (#121)
* Avoid to export Debug flags * Fix typo and add more options
1 parent a7ee8c8 commit 46995f6

File tree

5 files changed

+37
-8
lines changed

5 files changed

+37
-8
lines changed

CMakeLists.txt

+27-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,28 @@ set(TARGET_ALIAS ${TARGET_NAMESPACE}::${TARGET_NAME})
1919
set(TARGET_PACKAGE_NAME ${PROJECT_NAME}-config)
2020
set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-targets)
2121

22+
option(
23+
BEMAN_EXECUTION26_ENABLE_TESTING
24+
"Enable building tests and test infrastructure. Values: { ON, OFF }."
25+
${PROJECT_IS_TOP_LEVEL}
26+
)
27+
28+
option(
29+
BEMAN_EXECUTION26_BUILD_EXAMPLES
30+
"Enable building examples. Values: { ON, OFF }."
31+
${PROJECT_IS_TOP_LEVEL}
32+
)
33+
34+
option(
35+
BEMAN_EXECUTION26_ENABLE_INSTALL
36+
"Install the project components. Values: { ON, OFF }."
37+
${PROJECT_IS_TOP_LEVEL}
38+
)
39+
2240
include(GNUInstallDirs)
2341
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
2442

25-
if(CMAKE_BUILD_TYPE STREQUAL xDebug)
43+
if(NOT BEMAN_EXECUTION26_ENABLE_INSTALL OR CMAKE_SKIP_INSTALL_RULES)
2644
include(FetchContent)
2745

2846
# Add project_options from https://github.com/aminya/project_options
@@ -73,13 +91,20 @@ endif()
7391

7492
add_subdirectory(src/beman/execution26)
7593

76-
if(PROJECT_IS_TOP_LEVEL)
94+
if(BEMAN_EXECUTION26_ENABLE_TESTING)
7795
enable_testing()
7896

7997
add_subdirectory(tests/beman/execution26)
98+
endif()
99+
100+
if(BEMAN_EXECUTION26_BUILD_EXAMPLES)
80101
add_subdirectory(examples)
81102
endif()
82103

104+
if(NOT BEMAN_EXECUTION26_ENABLE_INSTALL OR CMAKE_SKIP_INSTALL_RULES)
105+
return()
106+
endif()
107+
83108
include(CMakePackageConfigHelpers)
84109

85110
write_basic_package_version_file(

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ doc:
7979

8080
build:
8181
CC=$(CXX) cmake --fresh -G Ninja -S $(SOURCEDIR) -B $(BUILD) $(TOOLCHAIN) $(SYSROOT) \
82-
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
83-
-DCMAKE_CXX_COMPILER=$(CXX) # XXX -DCMAKE_CXX_FLAGS="$(CXX_FLAGS) $(SAN_FLAGS)"
82+
-D CMAKE_EXPORT_COMPILE_COMMANDS=1 \
83+
-D CMAKE_SKIP_INSTALL_RULES=1 \
84+
-D CMAKE_CXX_COMPILER=$(CXX) # XXX -D CMAKE_CXX_FLAGS="$(CXX_FLAGS) $(SAN_FLAGS)"
8485
cmake --build $(BUILD)
8586

8687
# NOTE: without install! CK

cmake/CMakeLinuxPresets.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
"name": "release-base-Linux",
2121
"hidden": true,
2222
"cacheVariables": {
23-
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
24-
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Wno-shadow -Wconversion -Wsign-conversion -Wcast-align -Wcast-qual -Woverloaded-virtual -Wformat=2 -Wno-error"
23+
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
2524
},
2625
"condition": {
2726
"type": "notEquals",

src/beman/execution26/CMakeLists.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
add_library(${TARGET_NAME} STATIC)
77
add_library(${TARGET_ALIAS} ALIAS ${TARGET_NAME})
88

9-
if(CMAKE_BUILD_TYPE STREQUAL xDebug)
9+
if(NOT BEMAN_EXECUTION26_ENABLE_INSTALL OR CMAKE_SKIP_INSTALL_RULES)
1010
target_link_libraries(${TARGET_NAME} PUBLIC $<BUILD_INTERFACE:${TARGET_NAME}_project_options>)
1111
target_link_libraries(${TARGET_NAME} PUBLIC $<BUILD_INTERFACE:${TARGET_NAME}_project_warnings>)
1212
endif()
@@ -198,6 +198,10 @@ target_compile_features(${TARGET_NAME} PUBLIC
198198
"$<$<NOT:$<COMPILE_FEATURES:cxx_std_26>>:cxx_std_23>"
199199
)
200200

201+
if(NOT BEMAN_EXECUTION26_ENABLE_INSTALL OR CMAKE_SKIP_INSTALL_RULES)
202+
return()
203+
endif()
204+
201205
install(
202206
TARGETS ${TARGET_NAME}
203207
EXPORT ${TARGETS_EXPORT_NAME}1

tests/beman/execution26/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ foreach(test ${execution_tests})
129129
add_test(NAME ${TEST_EXE} COMMAND $<TARGET_FILE:${TEST_EXE}>)
130130
endforeach()
131131

132-
if(ROJECT_IS_TOP_LEVEL)
132+
if(NOT PROJECT_IS_TOP_LEVEL AND BEMAN_EXECUTION26_ENABLE_TESTING)
133133
# test if the targets are findable from the build directory
134134
# cmake-format: off
135135
add_test(NAME find-package-test

0 commit comments

Comments
 (0)