Code Coverage
Instruments builds, runs tests, and generates an HTML report via gcovr. Enforces 100% line coverage — the build fails if any line goes untested. Supports GCC and Clang 18 on Linux.
Writing a redistributable C++ library requires the same CMake boilerplate on every project: coverage reporting,
compiler sanitizers, version stamping, install rules, config-mode package files, and release packaging.
cmake-library-support packages all of that as seven independently-includable modules consumed
via FetchContent.
There is no installation step. Add the dependency, include only the modules you need, and the boilerplate is done. Every module targets the specific workflow of a C++ library author — nothing more.
Instruments builds, runs tests, and generates an HTML report via gcovr. Enforces 100% line coverage — the build fails if any line goes untested. Supports GCC and Clang 18 on Linux.
Applies AddressSanitizer, UndefinedBehaviorSanitizer, ThreadSanitizer, MemorySanitizer, or LeakSanitizer with compile-time validation that the requested sanitizer is supported by the active compiler.
Appends the short commit hash and a -dirty suffix to the project version on non-release branches, keeping every debug build traceable back to its exact source state.
Downloads and caches private GitHub release assets by SHA256 checksum. Automatically sanitizes GH_TOKEN from any error output so credentials never appear in CI logs.
Generates a <package>-config.cmake.in template for configure_package_config_file(), enabling find_package() support in downstream projects with no manual template authoring.
Installs static, shared, and interface library targets with correct CMake export sets and config-mode package files — ready for downstream consumption immediately after cmake --install.
Configures CPack to produce named archives — .tar.gz on Linux and macOS, .zip on Windows — with system and architecture embedded in the filename.
Add to any CMake project via FetchContent (replace vX.Y.Z with the latest release):
include(FetchContent)
FetchContent_Declare(
cmake-library-support
GIT_REPOSITORY https://github.com/donut-engineer/cmake-library-support.git
GIT_TAG vX.Y.Z
)
FetchContent_MakeAvailable(cmake-library-support)
# Include only the modules you need
include(coverage)
include(sanitizers)
include(install-rules)
include(package-rules)
After FetchContent_MakeAvailable, modules are available on CMAKE_MODULE_PATH automatically.
CMake 3.15+ for all modules. CMake 3.18+ required for github-release-dependency (file(ARCHIVE_EXTRACT)).
Coverage requires gcovr 5+ (pip install gcovr) and either GCC or Clang 18 on Linux or macOS.