添加以下4个变量,通过build_type来控制,或者直接加入到四个原始变量中即可,
如果是动态库方式,可以删除-static-libasan相关的两个配置,编译好之后可以通过
ldd file|grep san来查看是否编译进去。
export ASAN_OPTIONS=halt_on_error=0;
SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
"Choose the type of build, options are:
None Debug Release RelWithDebInfo Asan Pprof."
FORCE )
message("* Current build type is : ${CMAKE_BUILD_TYPE}")
# 置C++ 编译选项,也可以通过指令ADD_DEFINITIONS
SET( CMAKE_CXX_FLAGS_ASAN "-O2 -g -fsanitize=address -fno-omit-
frame-pointer" CACHE STRING
"Flags used by the C++ compiler during asan builds."
FORCE )
# C编译权限