From 89ef74ab34462955ff4966a8638e60465834b216 Mon Sep 17 00:00:00 2001 From: Geoffray Levasseur Date: Thu, 26 Nov 2026 15:02:01 +0100 Subject: [PATCH] add usefull debug option --- CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33395ab..43825f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,22 @@ foreach(_cevo_dir AIDIR RESOURCEDIR) endif() endforeach() +option(ENABLE_ASAN "Activer AddressSanitizer" OFF) + +if(ENABLE_ASAN) + if(MSVC) + # Sous Windows avec MSVC : /fsanitize=address et symboles /Zi + # Évitez /ZI (Edit and Continue), incompatible avec ASan sous MSVC + add_compile_options(/fsanitize=address /Zi /fno-omit-frame-pointer) + string(REPLACE "/ZI" "/Zi" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + string(REPLACE "/ZI" "/Zi" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") + else() + # Sous Linux (GCC / Clang) et MinGW/Clang sous Windows + add_compile_options(-fsanitize=address -fno-omit-frame-pointer -g) + add_link_options(-fsanitize=address) + endif() +endif() + # ai/ is the generic AI-plugin interface: needed by the app (to load AI # modules at runtime) and by the bundled stdai plugin (as its base classes). if(CEVO_WITH_APP OR CEVO_WITH_AI)