From aa4feeed7b374dde9bd5935cf956f2ae38bb0ab2 Mon Sep 17 00:00:00 2001 From: Brian Bockelman Date: Sun, 24 Nov 2024 20:23:46 -0600 Subject: [PATCH] Enable address sanitizer for debug builds --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 49509a5..9eac80b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,12 @@ if(VALGRIND) find_program(VALGRIND_BIN valgrind REQUIRED) endif() +if(CMAKE_BUILD_TYPE MATCHES Debug) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") + set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=address") +endif() + macro(use_cxx17) if (CMAKE_VERSION VERSION_LESS "3.1") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")