CMake: Add support for Undefined Behavior sanitizer

pull/1480/head
Turo Lamminen 2017-10-07 17:13:08 +03:00
parent 8e7f476490
commit 6efe4e2841
1 changed files with 10 additions and 0 deletions

View File

@ -86,6 +86,10 @@ OPTION ( ASSIMP_ASAN
"Enable AddressSanitizer."
OFF
)
OPTION ( ASSIMP_UBSAN
"Enable Undefined Behavior sanitizer."
OFF
)
OPTION ( SYSTEM_IRRXML
"Use system installed Irrlicht/IrrXML library."
OFF
@ -234,6 +238,12 @@ if (ASSIMP_ASAN)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
endif()
if (ASSIMP_UBSAN)
MESSAGE(STATUS "Undefined Behavior sanitizer enabled")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
endif()
INCLUDE (FindPkgMacros)
INCLUDE (PrecompiledHeader)