+macro(check_sanitizer VAR NAME LIB)
+ message(STATUS "Checking for sanitizer: ${NAME} (-l${LIB})")
+ if(${NAME} IN_LIST ${VAR} OR ${LIB} IN_LIST ${VAR})
+ safe_string(${LIB} ID)
+ cmake_push_check_state(RESET)
+ set(CMAKE_REQUIRED_LIBRARIES ${LIB})
+ check_cxx_compiler_flag(-fsanitize=${NAME} HAVE_${ID})
+ cmake_pop_check_state()
+ if(HAVE_${ID})
+ add_compile_definitions(HAVE_${ID})
+ add_compile_options(-fsanitize=${NAME})
+ link_libraries(-fsanitize=${NAME})
+ check_flag(-fsanitize-recover=${NAME} IGNORE)
+ message(STATUS " OK")
+ else()
+ message(STATUS " NO: not supported")
+ endif()
+ else()
+ message(STATUS " NO: not requested")
+ endif()
+endmacro()
+