cmake: Add easy sanitizers option
Set -DSANITIZE to a comma-separated list of options to pass to -fsanitize=, like -DSANITIZE=address,undefined
This commit is contained in:
parent
216b8e045d
commit
fbf753257b
|
@ -27,6 +27,7 @@ include(CMakeDependentOption)
|
||||||
include(CheckIPOSupported)
|
include(CheckIPOSupported)
|
||||||
|
|
||||||
include(SetupCCache)
|
include(SetupCCache)
|
||||||
|
include(Sanitizers)
|
||||||
|
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
set(SANITIZE "" CACHE STRING "Sanitizers to enable.")
|
||||||
|
|
||||||
|
string(REGEX MATCHALL "[^,]+" ENABLED_SANITIZERS "${SANITIZE}")
|
||||||
|
|
||||||
|
foreach(SANITIZER ${ENABLED_SANITIZERS})
|
||||||
|
add_compile_options("-fsanitize=${SANITIZER}")
|
||||||
|
add_link_options("-fsanitize=${SANITIZER}")
|
||||||
|
endforeach()
|
Loading…
Reference in New Issue