sanitizer: add an option to enable various sanitizers

This commit is contained in:
Danny Robson 2018-07-04 16:25:05 +10:00
parent 9198bae72d
commit 878a1f118f
2 changed files with 15 additions and 0 deletions

View File

@ -14,6 +14,7 @@ find_package (Threads REQUIRED)
link_libraries (Threads::Threads)
include (nc_cxx)
include (nc_sanitizer)
include (nc_platform)
include (nc_optimisation)
include (nc_warnings)

14
nc_sanitizer.cmake Normal file
View File

@ -0,0 +1,14 @@
option (SANITIZER "enable sanitizers" OFF)
if (SANITIZER)
append_compile_flag("-fsanitize=undefined")
append_compile_flag("-fsanitize=address")
append_compile_flag("-fsanitize=leak")
append_compile_flag("--param max-gcse-memory=167772160")
append_compile_flag("-fsanitize=pointer-compare")
append_compile_flag("-fsanitize=pointer-subtract")
add_definitions("-D_GLIBCXX_SANITIZE_VECTOR")
endif()