Browse Source

CMake: Add support for Undefined Behavior sanitizer

Turo Lamminen 8 years ago
parent
commit
6efe4e2841
1 changed files with 10 additions and 0 deletions
  1. 10 0
      CMakeLists.txt

+ 10 - 0
CMakeLists.txt

@@ -86,6 +86,10 @@ OPTION ( ASSIMP_ASAN
   "Enable AddressSanitizer."
   "Enable AddressSanitizer."
   OFF
   OFF
 )
 )
+OPTION ( ASSIMP_UBSAN
+  "Enable Undefined Behavior sanitizer."
+  OFF
+)
 OPTION ( SYSTEM_IRRXML
 OPTION ( SYSTEM_IRRXML
   "Use system installed Irrlicht/IrrXML library."
   "Use system installed Irrlicht/IrrXML library."
   OFF
   OFF
@@ -234,6 +238,12 @@ if (ASSIMP_ASAN)
     SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
     SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
 endif()
 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 (FindPkgMacros)
 INCLUDE (PrecompiledHeader)
 INCLUDE (PrecompiledHeader)