From e1ceca109fdc32839eb752b3e3133d58a0903a50 Mon Sep 17 00:00:00 2001 From: zhenyan121 <3367366583@qq.com> Date: Thu, 12 Mar 2026 15:37:28 +0800 Subject: [PATCH] feat: add AddressSanitizer --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b903707..ca10835 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,20 @@ add_executable(${PROJECT_NAME} src/tools/log.cpp ) +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + message(STATUS "Building with AddressSanitizer enabled for target: ${PROJECT_NAME}") + + target_compile_options(${PROJECT_NAME} PRIVATE + -fsanitize=address + -fno-omit-frame-pointer + -g + ) + + target_link_options(${PROJECT_NAME} PRIVATE + -fsanitize=address + ) +endif() + target_include_directories(${PROJECT_NAME} PUBLIC ${INCLUDE_DIR}) target_link_libraries(${PROJECT_NAME}