- -Wdouble-promotion
- -Wduplicated-cond
- -Wduplicated-branches
- -Wformat=2
- -Wlogical-op
- -Wnull-dereference
- -Wrestrict
- -Wshadow
- -Wunknown-pragmas
- -Wunsafe-loop-optimizations
- )
- unset(FLAG_CONSTANT)
- string(MAKE_C_IDENTIFIER CXX${FLAG} FLAG_CONSTANT)
- check_cxx_compiler_flag(${FLAG} ${FLAG_CONSTANT})
- if(${FLAG_CONSTANT})
- add_compile_options(${FLAG})
- endif()
- endforeach()
-
- if(ENABLE_SANITIZERS)
- if(address IN_LIST ENABLE_SANITIZERS OR asan IN_LIST ENABLE_SANITIZERS)
- cmake_push_check_state(RESET)
- set(CMAKE_REQUIRED_LIBRARIES asan)
- check_cxx_compiler_flag(-fsanitize=address HAVE_ASAN)
- cmake_pop_check_state()
- if(HAVE_ASAN)
- add_compile_options(-fsanitize=address)
- add_link_options(-lasan)
+ if(ENABLE_SANITIZERS)
+ if(address IN_LIST ENABLE_SANITIZERS OR asan IN_LIST ENABLE_SANITIZERS)
+ cmake_push_check_state(RESET)
+ set(CMAKE_REQUIRED_LIBRARIES asan)
+ check_cxx_compiler_flag(-fsanitize=address HAVE_ASAN)
+ cmake_pop_check_state()
+ if(HAVE_ASAN)
+ add_compile_definitions(HAVE_ASAN)
+ add_compile_options(-fsanitize=address)
+ link_libraries(-fsanitize=address)
+ check_flag(-fsanitize-recover=address IGNORE)
+ endif()