This directory contains custom CMake modules and utilities for the project.
The project provides several configuration options:
| Option | Description | Default |
|---|---|---|
BUILD_TESTS |
Build test suite | ON (main project) |
BUILD_EXAMPLES |
Build example applications | ON (main project) |
BUILD_PYTHON_BINDINGS |
Build Python bindings with pybind11 | OFF |
ENABLE_WARNINGS |
Enable compiler warnings | ON |
WARNINGS_AS_ERRORS |
Treat warnings as errors | OFF |
ENABLE_CLANG_TIDY |
Enable clang-tidy static analysis | OFF |
ENABLE_CPPCHECK |
Enable cppcheck static analysis | OFF |
Provides the add_module() function to simplify creating project modules.
Usage:
include(ModuleHelpers)
add_module(concepts) # Header-only module
add_module(memory SOURCES resource_management.cpp) # Regular module with sources
add_module(network DEPENDENCIES OpenSSL::SSL) # Module with dependenciesFeatures:
- Automatically creates proper target names and namespaced aliases
- Sets up include directories for both build and install interfaces
- Links to project options and warnings targets
- Configures installation rules
Manages external project dependencies using a find-first, fetch-fallback approach.
Usage:
include(Dependencies)
setup_project_dependencies()Currently handles:
- Catch2: Modern C++ testing framework (only when
BUILD_TESTSis enabled) - pybind11: Python bindings (only when
BUILD_PYTHON_BINDINGSis enabled)
Features:
- Uses
find_package()first to find system-installed dependencies - Falls back to
FetchContentwhen dependencies are not found - Automatically configures CMake modules for test discovery
Provides the set_project_warnings() function to apply comprehensive compiler warnings across different compilers.
Warnings can optionally be treated as errors.
Usage:
include(CompilerWarnings)
add_library(demo_project_warnings INTERFACE)
set_project_warnings(demo_project_warnings)Configures static analysis tools:
- clang-tidy: Enable with
-DENABLE_CLANG_TIDY=ON - cppcheck: Enable with
-DENABLE_CPPCHECK=ON
Template for the package configuration file that allows other projects to find and use this package with find_package().
This build system follows modern CMake best practices:
- Target-based approach: Uses targets instead of global variables
- Interface libraries: For sharing common settings across targets
- Generator expressions: For build-type specific configurations
- Proper installation: With package config files for easy consumption
- Modular structure: Each component is a separate library
- Namespace aliases: All targets have
${PROJECT_NAME}::namespaced aliases