CMake modules to enable compiler sanitizers (AddressSanitizer, MemorySanitizer, etc.) for C/C++/Fortran projects.
sanitizers-cmake is a collection of CMake modules that simplify enabling compiler sanitizers in CMake-based C, C++, and Fortran projects. It provides a standardized way to integrate tools like AddressSanitizer, MemorySanitizer, ThreadSanitizer, and UndefinedBehaviorSanitizer to detect runtime bugs such as memory leaks, data races, and undefined behavior during development and testing.
C/C++/Fortran developers using CMake as their build system who want to incorporate sanitizer-based runtime analysis into their workflow without manual compiler flag management.
It abstracts away compiler-specific sanitizer flags and compatibility issues, offers cross-compiler support with graceful degradation, and integrates cleanly into existing CMake projects with minimal configuration.
CMake modules to help use sanitizers
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows enabling sanitizers via simple CMake options like -DSANITIZE_ADDRESS=On, abstracting away complex compiler-specific flags as shown in the README usage examples.
Detects compiler capabilities and disables sanitizers for unsupported compilers or mixed-language targets, preventing linking issues and ensuring builds continue with warnings.
Issues warnings but doesn't fail CMake processing if sanitizers are unsupported, making it non-intrusive and safe for diverse build environments.
Provides sanitizer_add_blacklist_file() to exclude specific functions or source files from analysis, offering customization for complex projects.
Requires adding the project as a git submodule or manually copying files, which can complicate setup and updates, as noted in the inclusion instructions.
Primarily supports GCC and Clang; the README mentions problems with Intel compiler and mixed toolchains, limiting portability and requiring workarounds.
AddressSanitizer issues with preloading or dynamic linking are acknowledged, necessitating the use of SANITIZE_LINK_STATIC or the asan-wrapper script as fixes.