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)