-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathsanitizers.cmake
More file actions
23 lines (23 loc) · 882 Bytes
/
sanitizers.cmake
File metadata and controls
23 lines (23 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
option(ENABLE_ADDRESS_SANITIZER OFF)
option(ENABLE_UB_SANITIZER OFF)
option(ENABLE_LEAK_SANITIZER OFF)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if(ENABLE_ADDRESS_SANITIZER)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
message(STATUS "Enabled address sanitizer")
endif()
if(ENABLE_UB_SANITIZER)
add_compile_options(-fsanitize=undefined
-fno-sanitize=signed-integer-overflow)
add_link_options(-fsanitize=undefined -fno-sanitize=signed-integer-overflow)
message(STATUS "Enabled UB sanitizer")
endif()
if(ENABLE_LEAK_SANITIZER)
add_compile_options(-fsanitize=leak)
add_link_options(-fsanitize=leak)
message(STATUS "Enabled leak sanitizer")
endif()
else()
message(WARNING "Sanitizers are supported on gcc and clang compilers only!")
endif()