From 6efe4e2841d710a7b3db44a9264fc8c2f52f1990 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 7 Oct 2017 17:13:08 +0300 Subject: [PATCH] CMake: Add support for Undefined Behavior sanitizer --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c30278b7f..bc3731bbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)