Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. CMake
  3. sanitizers-cmake

sanitizers-cmake

NOASSERTIONCMake

CMake modules to enable compiler sanitizers (AddressSanitizer, MemorySanitizer, etc.) for C/C++/Fortran projects.

GitHubGitHub
411 stars74 forks0 contributors

What is sanitizers-cmake?

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.

Target Audience

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.

Value Proposition

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.

Overview

CMake modules to help use sanitizers

Use Cases

Best For

  • Enabling AddressSanitizer for memory error detection in CMake projects
  • Adding ThreadSanitizer support to catch data races in multi-threaded C++ code
  • Integrating UndefinedBehaviorSanitizer to detect undefined behavior at runtime
  • Setting up sanitizers for mixed C/C++/Fortran projects with different compilers
  • Creating sanitizer blacklists to exclude specific functions from analysis
  • Preloading AddressSanitizer libraries in LD_PRELOAD environments

Not Ideal For

  • Projects using non-CMake build systems like Meson or Bazel
  • Developers who require fine-grained, manual control over sanitizer compiler flags
  • Production builds where sanitizer runtime overhead is unacceptable and minimal configuration is needed
  • Teams with strict policies against git submodules or external dependencies

Pros & Cons

Pros

Easy Sanitizer Enablement

Allows enabling sanitizers via simple CMake options like -DSANITIZE_ADDRESS=On, abstracting away complex compiler-specific flags as shown in the README usage examples.

Automatic Compiler Detection

Detects compiler capabilities and disables sanitizers for unsupported compilers or mixed-language targets, preventing linking issues and ensuring builds continue with warnings.

Graceful Degradation

Issues warnings but doesn't fail CMake processing if sanitizers are unsupported, making it non-intrusive and safe for diverse build environments.

Blacklist Support

Provides sanitizer_add_blacklist_file() to exclude specific functions or source files from analysis, offering customization for complex projects.

Cons

Git Submodule Dependency

Requires adding the project as a git submodule or manually copying files, which can complicate setup and updates, as noted in the inclusion instructions.

Compiler Compatibility Issues

Primarily supports GCC and Clang; the README mentions problems with Intel compiler and mixed toolchains, limiting portability and requiring workarounds.

Dynamic Linking Challenges

AddressSanitizer issues with preloading or dynamic linking are acknowledged, necessitating the use of SANITIZE_LINK_STATIC or the asan-wrapper script as fixes.

Frequently Asked Questions

Quick Stats

Stars411
Forks74
Contributors0
Open Issues10
Last commit8 months ago
CreatedSince 2013

Tags

#memory-safety#c#cmake#c-plus-plus#fortran#static-analysis

Built With

C
CMake

Included in

CMake5.4k
Auto-fetched 17 hours ago

Related Projects

cotirecotire

CMake module to speed up builds.

Stars1,298
Forks140
Last commit6 years ago
cmakeppcmakepp

An Enhancement Suite for the CMake Build System

Stars448
Forks37
Last commit4 years ago
DownloadProjectDownloadProject

This repository is no longer maintained. Use the FetchContent module available in CMake 3.11 or later instead.

Stars444
Forks88
Last commit2 years ago
ucmucm

Useful cmake macros that help with: compiler/linker flags, collecting sources, PCHs, Unity builds and other stuff.

Stars214
Forks33
Last commit3 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub