From 397d0f52c3bedea1dc41c448f74fe1170587e4e9 Mon Sep 17 00:00:00 2001 From: "Christian W. Zuckschwerdt" Date: Fri, 5 Jun 2026 16:06:45 +0200 Subject: [PATCH] build: Fix to use asan/ubsan on Linux only --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d6796e6..46b1f3dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,8 +96,10 @@ if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" MATCHES # set(CMAKE_C_FLAGS_RELEASE -O2) # CMake Debug default for GCC/Clang is "-g -DNDEBUG" # set(CMAKE_C_FLAGS_DEBUG -g3 -O0) - # make use of ASAN - set(CMAKE_C_FLAGS_DEBUG "-ggdb -fsanitize=undefined -fsanitize=address -fno-omit-frame-pointer") + set(CMAKE_C_FLAGS_DEBUG "-ggdb -fno-omit-frame-pointer") + # make use of ASAN only on Linux + add_compile_options($<$,$>:-fsanitize=undefined$-fsanitize=address>) + link_libraries($<$,$>:-fsanitize=undefined$-fsanitize=address>) endif() if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") # make sure we don't accidentally copy more than an int