diff --git a/CMakeLists.txt b/CMakeLists.txt index 2de8e685..8659ebff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,8 +12,14 @@ include(FetchContent) set(TARGETS_EXPORT_NAME ${PROJECT_NAME}Targets) option( - OPTIONAL_ENABLE_TESTING - "Enable building tests and test infrastructure" + BEMAN_OPTIONAL_BUILD_TESTS + "Enable building tests and test infrastructure. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }." + ${PROJECT_IS_TOP_LEVEL} +) + +option( + BEMAN_OPTIONAL_BUILD_EXAMPLES + "Enable building examples. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }." ${PROJECT_IS_TOP_LEVEL} ) @@ -27,7 +33,7 @@ target_sources( PUBLIC FILE_SET beman_optional_headers TYPE HEADERS BASE_DIRS include ) -if(OPTIONAL_ENABLE_TESTING) +if(BEMAN_OPTIONAL_BUILD_TESTS) find_package(GTest QUIET) if(GTest_FOUND) # Create the library target and named header set for testing beman.optional @@ -57,7 +63,9 @@ endif() add_subdirectory(include/beman/optional) -add_subdirectory(examples) +if(BEMAN_OPTIONAL_BUILD_EXAMPLES) + add_subdirectory(examples) +endif() include(infra/cmake/beman-install-library.cmake) beman_install_library(beman.optional TARGETS beman.optional) diff --git a/README.md b/README.md index 7755e71e..8d143ffd 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,22 @@ The README itself is licensed with CC0 1.0 Universal. Copy the contents and inco // SPDX-License-Identifier: CC0-1.0 +## Dependencies + +### Build Environment + +This project requires at least the following to build: + +* A C++ compiler that conforms to the C++20 standard or greater +* CMake 3.27 or later +* (Test Only) GoogleTest + +You can disable building tests by setting CMake option `BEMAN_OPTIONAL_BUILD_TESTS` to +`OFF` when configuring the project. + +You can disable building examples by setting CMake option `BEMAN_OPTIONAL_BUILD_EXAMPLES` to +`OFF` when configuring the project. + ## How to Build ### Compiler Support @@ -192,7 +208,7 @@ consequently have the highest optimization turned on (e.g. `O3`). CI current build and test flows: ```shell -# Configure build: default build production code + tests (OPTIONAL_ENABLE_TESTING=ON by default). +# Configure build: default build production code + tests (BEMAN_OPTIONAL_BUILD_TESTS=ON by default). $ cmake -G "Ninja Multi-Config" \ -DCMAKE_CONFIGURATION_TYPES="RelWithDebInfo;Asan" \ -DCMAKE_TOOLCHAIN_FILE=etc/clang-19-toolchain.cmake \ @@ -218,14 +234,15 @@ Total Test time (real) = 0.67 sec ##### Build Production, but Skip Tests -By default, we build and run tests. You can provide `-DOPTIONAL_ENABLE_TESTING=OFF` and completely disable building tests: +By default, we build and run tests. You can disable building tests by setting CMake +option `BEMAN_OPTIONAL_BUILD_TESTS` to `OFF` when configuring the project: ```shell -# Configure build: build production code, skip tests (OPTIONAL_ENABLE_TESTING=OFF). +# Configure build: build production code, skip tests (BEMAN_OPTIONAL_BUILD_TESTS=OFF). $ cmake -G "Ninja Multi-Config" \ -DCMAKE_CONFIGURATION_TYPES="RelWithDebInfo;Asan" \ -DCMAKE_TOOLCHAIN_FILE=etc/clang-19-toolchain.cmake \ - -DOPTIONAL_ENABLE_TESTING=OFF \ + -DBEMAN_OPTIONAL_BUILD_TESTS=OFF \ -B .build -S . -- The CXX compiler identification is Clang 19.0.0 ...