1 include(CMakePushCheckState)
2 include(CheckCXXCompilerFlag)
5 if(CMAKE_BUILD_TYPE STREQUAL "Debug")
6 add_compile_options(-O1)
7 add_definitions(-DDEBUG=1)
10 -fno-omit-frame-pointer
11 -fno-eliminate-unused-debug-types
12 -funsafe-loop-optimizations
28 -Wunsafe-loop-optimizations
31 string(MAKE_C_IDENTIFIER CXX${FLAG} FLAG_CONSTANT)
32 check_cxx_compiler_flag(${FLAG} ${FLAG_CONSTANT})
34 add_compile_options(${FLAG})
39 if(address IN_LIST ENABLE_SANITIZERS OR asan IN_LIST ENABLE_SANITIZERS)
40 cmake_push_check_state(RESET)
41 set(CMAKE_REQUIRED_LIBRARIES asan)
42 check_cxx_compiler_flag(-fsanitize=address HAVE_ASAN)
43 cmake_pop_check_state()
45 add_compile_options(-fsanitize=address)
46 add_link_options(-lasan)
50 if(undefined IN_LIST ENABLE_SANITIZERS OR ubsan IN_LIST ENABLE_SANITIZERS)
51 cmake_push_check_state(RESET)
52 set(CMAKE_REQUIRED_LIBRARIES ubsan)
53 check_cxx_compiler_flag(-fsanitize=undefined HAVE_UBSAN)
54 cmake_pop_check_state()
56 add_compile_options(-fsanitize=undefined)
57 add_link_options(-lubsan)
62 add_definitions(-DDEBUG=0)