# CMake Directory (`cmake/`) This directory contains CMake configuration files and build system utilities. ## Structure ``` cmake/ ├── modules/ # Custom CMake modules │ ├── FindGoogleTest.cmake # Google Test finder │ ├── FindGoogleBenchmark.cmake # Google Benchmark finder │ ├── CompilerWarnings.cmake # Compiler warning configuration │ └── StaticAnalysis.cmake # Static analysis tools ├── toolchains/ # Cross-compilation toolchains │ ├── gcc.cmake # GCC toolchain │ ├── clang.cmake # Clang toolchain │ └── mingw.cmake # MinGW cross-compilation ├── packaging/ # CPack configuration │ ├── DEB.cmake # Debian package configuration │ ├── RPM.cmake # RPM package configuration │ └── NSIS.cmake # Windows installer configuration └── presets/ # CMake presets ├── debug.cmake # Debug build configuration ├── release.cmake # Release build configuration └── profile.cmake # Profiling build configuration ``` ## Key Features ### Build Configurations - **Debug**: Full debugging symbols, no optimization, sanitizers enabled - **Release**: Full optimization, minimal debug info, assertions disabled - **RelWithDebInfo**: Optimized with debug symbols for profiling - **Profile**: Special build for performance profiling ### Compiler Support - **GCC 9+**: Primary compiler with full C++20 support - **Clang 10+**: Alternative compiler with excellent diagnostics - **MSVC 2019+**: Windows support with Visual Studio - **Cross-compilation**: Support for different target architectures ### Dependencies - **Automatic Discovery**: Find system-installed dependencies - **FetchContent**: Download and build dependencies automatically - **Conan Integration**: Package manager integration (optional) - **vcpkg Support**: Microsoft's package manager (optional) ### Static Analysis - **Clang-Tidy**: Static analysis and modernization - **Cppcheck**: Additional static analysis - **Include-what-you-use**: Header dependency analysis - **Sanitizers**: AddressSanitizer, UBSanitizer, ThreadSanitizer ### Testing Integration - **CTest**: Integrated test runner - **Google Test**: Unit testing framework - **Google Benchmark**: Performance benchmarking - **Coverage**: Code coverage reporting with lcov/gcov ## Usage ### Basic Build ```bash mkdir build && cd build cmake .. cmake --build . ``` ### Advanced Configuration ```bash # Debug build with sanitizers cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_SANITIZERS=ON .. # Release build with static analysis cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_STATIC_ANALYSIS=ON .. # Cross-compile for ARM cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/arm-linux.cmake .. ``` ### CMake Presets (CMake 3.19+) ```bash # Use predefined presets cmake --preset debug cmake --build --preset debug cmake --preset release cmake --build --preset release ``` ## Build Options - `BUILD_TESTS`: Build unit tests (default: ON) - `BUILD_BENCHMARKS`: Build performance benchmarks (default: OFF) - `BUILD_EXAMPLES`: Build example programs (default: ON) - `ENABLE_SANITIZERS`: Enable runtime sanitizers (default: OFF in Release) - `ENABLE_STATIC_ANALYSIS`: Run static analysis tools (default: OFF) - `ENABLE_COVERAGE`: Generate code coverage reports (default: OFF)