chore: add TDD workflow, behavioral guidelines, and ASan support
Add deps/Sanitizers.cmake for AddressSanitizer support (ENABLE_ASAN). Add TDD workflow and behavioral guidelines to AGENTS.md.
This commit is contained in:
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
# ==============================================================================
|
||||
# Sanitizers
|
||||
# ==============================================================================
|
||||
# AddressSanitizer (ASan) support.
|
||||
# Works with GCC/Clang on Linux and macOS, Clang on Windows (requires
|
||||
# compiler-rt with sanitizers), and MSVC on Windows (/fsanitize=address).
|
||||
#
|
||||
# Usage: cmake -DENABLE_ASAN=ON ...
|
||||
# ==============================================================================
|
||||
|
||||
option(ENABLE_ASAN "Build with AddressSanitizer" OFF)
|
||||
|
||||
if (ENABLE_ASAN)
|
||||
if (ENABLE_COVERAGE)
|
||||
message(FATAL_ERROR "ENABLE_ASAN and ENABLE_COVERAGE cannot be used together")
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
add_compile_options(/fsanitize=address)
|
||||
message(STATUS "ASan: enabled (MSVC)")
|
||||
elseif (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
|
||||
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
|
||||
add_link_options(-fsanitize=address)
|
||||
message(STATUS "ASan: enabled (${CMAKE_C_COMPILER_ID})")
|
||||
else()
|
||||
message(FATAL_ERROR "ENABLE_ASAN: unsupported compiler ${CMAKE_C_COMPILER_ID}")
|
||||
endif()
|
||||
endif()
|
||||
Reference in New Issue
Block a user