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

Avoid to export Debug flags #121

Merged
Merged
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
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 @@ -198,6 +198,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 @@ -129,7 +129,7 @@ foreach(test ${execution_tests})
add_test(NAME ${TEST_EXE} COMMAND $<TARGET_FILE:${TEST_EXE}>)
endforeach()

if(ROJECT_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
Loading