From 1f77da52388e9cd77661d1340a54f2003b04cca0 Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sun, 21 Feb 2016 20:30:02 +0100 Subject: [PATCH] Add a build-time option to easily enable run-time sanitizers available in recent versions of Clang and GCC. --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 646dbf46f..7c1a12c87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,7 @@ option (BUILD_SHARED "Build rawtherapee with shared libraries" OFF) option (WITH_BZIP "Build with Bzip2 support" ON) option (WITH_MYFILE_MMAP "Build using memory mapped file" ON) option (WITH_LTO "Build with link-time optimizations" OFF) +option (WITH_SAN "Build with run-time sanitizer" OFF) option (OPTION_OMP "Build with OpenMP support" ON) option (STRICT_MUTEX "True (recommended): MyMutex will behave like POSIX Mutex; False: MyMutex will behave like POSIX RecMutex; Note: forced to ON for Debug builds" ON) option (TRACE_MYRWMUTEX "Trace RT's custom R/W Mutex (Debug builds only); redirecting std::out to a file is strongly recommended!" OFF) @@ -274,6 +275,12 @@ if (WITH_LTO) SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") endif (WITH_LTO) +if (WITH_SAN) + SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${WITH_SAN}") + SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${WITH_SAN}") + SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${WITH_SAN}") +endif (WITH_SAN) + if (OPTION_OMP) find_package(OpenMP) if (OPENMP_FOUND)