From e84de4cf683cc14c094c4f41d8552e093b53ae02 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Mon, 20 Jan 2025 09:34:09 +0100 Subject: [PATCH 1/2] Avoid to export Debug flags --- CMakeLists.txt | 6 +++++- Makefile | 5 +++-- cmake/CMakeLinuxPresets.json | 3 +-- src/beman/execution26/CMakeLists.txt | 6 +++++- tests/beman/execution26/CMakeLists.txt | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb17055f..d17dca98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-targets) include(GNUInstallDirs) set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) -if(CMAKE_BUILD_TYPE STREQUAL xDebug) +if(CMAKE_SKIP_INSTALL_RULES) include(FetchContent) # Add project_options from https://github.com/aminya/project_options @@ -80,6 +80,10 @@ if(PROJECT_IS_TOP_LEVEL) add_subdirectory(examples) endif() +if(CMAKE_SKIP_INSTALL_RULES) + return() +endif() + include(CMakePackageConfigHelpers) write_basic_package_version_file( diff --git a/Makefile b/Makefile index df8947b4..d8949263 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/cmake/CMakeLinuxPresets.json b/cmake/CMakeLinuxPresets.json index beb1c487..5deaebeb 100644 --- a/cmake/CMakeLinuxPresets.json +++ b/cmake/CMakeLinuxPresets.json @@ -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", diff --git a/src/beman/execution26/CMakeLists.txt b/src/beman/execution26/CMakeLists.txt index f7dedf9d..57beff2a 100644 --- a/src/beman/execution26/CMakeLists.txt +++ b/src/beman/execution26/CMakeLists.txt @@ -6,7 +6,7 @@ add_library(${TARGET_NAME} STATIC) add_library(${TARGET_ALIAS} ALIAS ${TARGET_NAME}) -if(CMAKE_BUILD_TYPE STREQUAL xDebug) +if(CMAKE_SKIP_INSTALL_RULES) target_link_libraries(${TARGET_NAME} PUBLIC $) target_link_libraries(${TARGET_NAME} PUBLIC $) endif() @@ -198,6 +198,10 @@ target_compile_features(${TARGET_NAME} PUBLIC "$<$>:cxx_std_23>" ) +if(CMAKE_SKIP_INSTALL_RULES) + return() +endif() + install( TARGETS ${TARGET_NAME} EXPORT ${TARGETS_EXPORT_NAME}1 diff --git a/tests/beman/execution26/CMakeLists.txt b/tests/beman/execution26/CMakeLists.txt index 56a8d1c8..e52f90e0 100644 --- a/tests/beman/execution26/CMakeLists.txt +++ b/tests/beman/execution26/CMakeLists.txt @@ -129,7 +129,7 @@ foreach(test ${execution_tests}) add_test(NAME ${TEST_EXE} COMMAND $) endforeach() -if(ROJECT_IS_TOP_LEVEL) +if(NOT ROJECT_IS_TOP_LEVEL) # test if the targets are findable from the build directory # cmake-format: off add_test(NAME find-package-test From cd1fd9a48b96b39d93da62a5b56eba23af10038c Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Mon, 20 Jan 2025 13:43:18 +0100 Subject: [PATCH 2/2] Fix typo and add more options --- CMakeLists.txt | 27 +++++++++++++++++++++++--- src/beman/execution26/CMakeLists.txt | 4 ++-- tests/beman/execution26/CMakeLists.txt | 2 +- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d17dca98..bafae52b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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_SKIP_INSTALL_RULES) +if(NOT BEMAN_EXECUTION26_ENABLE_INSTALL OR CMAKE_SKIP_INSTALL_RULES) include(FetchContent) # Add project_options from https://github.com/aminya/project_options @@ -73,14 +91,17 @@ 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(CMAKE_SKIP_INSTALL_RULES) +if(NOT BEMAN_EXECUTION26_ENABLE_INSTALL OR CMAKE_SKIP_INSTALL_RULES) return() endif() diff --git a/src/beman/execution26/CMakeLists.txt b/src/beman/execution26/CMakeLists.txt index 57beff2a..86464a3c 100644 --- a/src/beman/execution26/CMakeLists.txt +++ b/src/beman/execution26/CMakeLists.txt @@ -6,7 +6,7 @@ add_library(${TARGET_NAME} STATIC) add_library(${TARGET_ALIAS} ALIAS ${TARGET_NAME}) -if(CMAKE_SKIP_INSTALL_RULES) +if(NOT BEMAN_EXECUTION26_ENABLE_INSTALL OR CMAKE_SKIP_INSTALL_RULES) target_link_libraries(${TARGET_NAME} PUBLIC $) target_link_libraries(${TARGET_NAME} PUBLIC $) endif() @@ -198,7 +198,7 @@ target_compile_features(${TARGET_NAME} PUBLIC "$<$>:cxx_std_23>" ) -if(CMAKE_SKIP_INSTALL_RULES) +if(NOT BEMAN_EXECUTION26_ENABLE_INSTALL OR CMAKE_SKIP_INSTALL_RULES) return() endif() diff --git a/tests/beman/execution26/CMakeLists.txt b/tests/beman/execution26/CMakeLists.txt index e52f90e0..c04e756d 100644 --- a/tests/beman/execution26/CMakeLists.txt +++ b/tests/beman/execution26/CMakeLists.txt @@ -129,7 +129,7 @@ foreach(test ${execution_tests}) add_test(NAME ${TEST_EXE} COMMAND $) endforeach() -if(NOT 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