diff --git a/CMakeLists.txt b/CMakeLists.txt index cb17055f..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_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 @@ -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( 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..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_BUILD_TYPE STREQUAL xDebug) +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,6 +198,10 @@ target_compile_features(${TARGET_NAME} PUBLIC "$<$>: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 diff --git a/tests/beman/execution26/CMakeLists.txt b/tests/beman/execution26/CMakeLists.txt index 56a8d1c8..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(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