Skip to content
Closed
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
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ 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}
)

Expand All @@ -27,7 +27,7 @@ target_sources(
PUBLIC FILE_SET beman_optional_headers TYPE HEADERS BASE_DIRS include
)

if(OPTIONAL_ENABLE_TESTING)
if(BEMAN_OPTIONAL_BUILD_TESTS)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find_package(GTest QUIET)
if(GTest_FOUND)
# Create the library target and named header set for testing beman.optional
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ Build-time dependencies:
* `cmake`
* `ninja`, `make`, or another CMake-supported build system
* CMake defaults to "Unix Makefiles" on POSIX systems
* (Test Only) GoogleTest

You can disable building tests by setting CMake option `BEMAN_OPTIONAL_BUILD_TESTS` to
`OFF` when configuring the project.

Example of installation on `Ubuntu 24.04`:

Expand Down Expand Up @@ -192,7 +196,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 \
Expand All @@ -218,14 +222,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
...
Expand Down