Skip to content

Commit

Permalink
Avoid to export Debug flags (#121)
Browse files Browse the repository at this point in the history
* Avoid to export Debug flags

* Fix typo and add more options
  • Loading branch information
ClausKlein authored and dietmarkuehl committed Jan 21, 2025
1 parent bcf5bc9 commit ae1ebe0
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
29 changes: 27 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,28 @@ set(TARGET_ALIAS ${TARGET_NAMESPACE}::${TARGET_NAME})
set(TARGET_PACKAGE_NAME ${PROJECT_NAME}-config)
set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-targets)

option(
BEMAN_EXECUTION26_ENABLE_TESTING
"Enable building tests and test infrastructure. Values: { ON, OFF }."
${PROJECT_IS_TOP_LEVEL}
)

option(
BEMAN_EXECUTION26_BUILD_EXAMPLES
"Enable building examples. Values: { ON, OFF }."
${PROJECT_IS_TOP_LEVEL}
)

option(
BEMAN_EXECUTION26_ENABLE_INSTALL
"Install the project components. Values: { ON, OFF }."
${PROJECT_IS_TOP_LEVEL}
)

include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})

if(CMAKE_BUILD_TYPE STREQUAL xDebug)
if(NOT BEMAN_EXECUTION26_ENABLE_INSTALL OR CMAKE_SKIP_INSTALL_RULES)
include(FetchContent)

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

add_subdirectory(src/beman/execution26)

if(PROJECT_IS_TOP_LEVEL)
if(BEMAN_EXECUTION26_ENABLE_TESTING)
enable_testing()

add_subdirectory(tests/beman/execution26)
endif()

if(BEMAN_EXECUTION26_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

if(NOT BEMAN_EXECUTION26_ENABLE_INSTALL OR CMAKE_SKIP_INSTALL_RULES)
return()
endif()

include(CMakePackageConfigHelpers)

write_basic_package_version_file(
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ doc:

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

# NOTE: without install! CK
Expand Down
3 changes: 1 addition & 2 deletions cmake/CMakeLinuxPresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"name": "release-base-Linux",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Wno-shadow -Wconversion -Wsign-conversion -Wcast-align -Wcast-qual -Woverloaded-virtual -Wformat=2 -Wno-error"
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
},
"condition": {
"type": "notEquals",
Expand Down
6 changes: 5 additions & 1 deletion src/beman/execution26/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
add_library(${TARGET_NAME} STATIC)
add_library(${TARGET_ALIAS} ALIAS ${TARGET_NAME})

if(CMAKE_BUILD_TYPE STREQUAL xDebug)
if(NOT BEMAN_EXECUTION26_ENABLE_INSTALL OR CMAKE_SKIP_INSTALL_RULES)
target_link_libraries(${TARGET_NAME} PUBLIC $<BUILD_INTERFACE:${TARGET_NAME}_project_options>)
target_link_libraries(${TARGET_NAME} PUBLIC $<BUILD_INTERFACE:${TARGET_NAME}_project_warnings>)
endif()
Expand Down Expand Up @@ -209,6 +209,10 @@ target_compile_features(${TARGET_NAME} PUBLIC
"$<$<NOT:$<COMPILE_FEATURES:cxx_std_26>>:cxx_std_23>"
)

if(NOT BEMAN_EXECUTION26_ENABLE_INSTALL OR CMAKE_SKIP_INSTALL_RULES)
return()
endif()

install(
TARGETS ${TARGET_NAME}
EXPORT ${TARGETS_EXPORT_NAME}1
Expand Down
2 changes: 1 addition & 1 deletion tests/beman/execution26/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ foreach(test ${execution_tests})
add_test(NAME ${TEST_EXE} COMMAND $<TARGET_FILE:${TEST_EXE}>)
endforeach()

if(NOT PROJECT_IS_TOP_LEVEL)
if(NOT PROJECT_IS_TOP_LEVEL AND BEMAN_EXECUTION26_ENABLE_TESTING)
# test if the targets are findable from the build directory
# cmake-format: off
add_test(NAME find-package-test
Expand Down

0 comments on commit ae1ebe0

Please sign in to comment.