set(compile_checks "${available_checks},${check}")
endif()
- set(CMAKE_REQUIRED_FLAGS "-fsanitize=${compile_checks}")
+ set(CMAKE_REQUIRED_FLAGS -fsanitize=${compile_checks})
check_c_source_compiles("int main() { return 0; }" HAS_SANITIZER_${check}
FAIL_REGEX "not supported|unrecognized command|unknown option")
if(NOT ${supported_checks} STREQUAL "")
message(STATUS "Address sanitizer is enabled: ${supported_checks}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${supported_checks}")
+ add_link_options(-fsanitize=${supported_checks})
else()
message(STATUS "Address sanitizer is not supported")
endif()
if(NOT ${supported_checks} STREQUAL "")
message(STATUS "Leak sanitizer is enabled: ${supported_checks}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${supported_checks}")
+ add_link_options(-fsanitize=${supported_checks})
else()
message(STATUS "Leak sanitizer is not supported")
endif()
if(NOT ${supported_checks} STREQUAL "")
message(STATUS "Memory sanitizer is enabled: ${supported_checks}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${supported_checks}")
+ add_link_options(-fsanitize=${supported_checks})
else()
message(STATUS "Memory sanitizer is not supported")
endif()
if(NOT ${supported_checks} STREQUAL "")
message(STATUS "Thread sanitizer is enabled: ${supported_checks}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${supported_checks}")
+ add_link_options(-fsanitize=${supported_checks})
else()
message(STATUS "Thread sanitizer is not supported")
endif()
if(NOT ${supported_checks} STREQUAL "")
message(STATUS "Undefined behavior sanitizer is enabled: ${supported_checks}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${supported_checks}")
+ add_link_options(-fsanitize=${supported_checks})
# Group sanitizer flag -fsanitize=undefined will automatically add alignment, even if
# it is not in our sanitize flag list, so we need to explicitly disable alignment sanitizing.