Skip to content
Open
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
16 changes: 12 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Comment on lines 14 to 24

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.

@steve-downey , I'm still proposing to do this change and align to the Beman Standard now. Do you agree?


Expand All @@ -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
Comment on lines +36 to 39
Expand Down Expand Up @@ -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)
Expand Down
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand All @@ -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
...
Expand Down