From ff7966befa0e15f14c0ce5e1a919421d5f6dc6b3 Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Tue, 24 Mar 2026 11:57:55 +0100 Subject: [PATCH] Added sanitizer --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c39ebc1..83e08b16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,8 @@ option(XPYT_USE_SHARED_XEUS_PYTHON "Link xpython and xpython_extension with the option(XPYT_EMSCRIPTEN_WASM_BUILD "Build for wasm with emscripten" OFF) +option(XPYT_SANITIZE_ADDRESS "Enable address sanitizer" OFF) + # Test options option(XPYT_BUILD_TESTS "xeus-python test suite" OFF) @@ -250,6 +252,10 @@ macro(xpyt_set_common_options target_name) CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") target_compile_options(${target_name} PUBLIC -Wunused-parameter -Wextra -Wreorder) + if (XPYT_SANITIZE_ADDRESS) + target_compile_options(${target_name} PUBLIC -fsanitize=address -fno-omit-frame-pointer) + target_link_options(${target_name} PUBLIC -fsanitize=address) + endif () endif () endmacro()