Skip to content
Snippets Groups Projects
Unverified Commit 901689de authored by Tomáš Pecka's avatar Tomáš Pecka
Browse files

CMake: remove sanitizers from cmake

parent c8e50ada
No related branches found
No related tags found
2 merge requests!144Merge tp,!143ci test do not merge
...@@ -3,10 +3,8 @@ ...@@ -3,10 +3,8 @@
# Flags according to Debug/Release decision # Flags according to Debug/Release decision
# - CMake uses -g on Debug implicitly # - CMake uses -g on Debug implicitly
# - fPIC for libraries will be enabled explicitly # - fPIC for libraries will be enabled explicitly
# sanitizer
   
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
include(sanitizer) # sanitizer -DSANITIZE=<sanitizer>
find_package(Backtrace) find_package(Backtrace)
   
message("[Build type]: ${BUILD_TYPE} (cmake: ${CMAKE_BUILD_TYPE})") message("[Build type]: ${BUILD_TYPE} (cmake: ${CMAKE_BUILD_TYPE})")
......
# Adapted from: https://github.com/Eyescale/CMake/blob/master/Sanitizer.cmake
if(NOT SANITIZER)
return()
endif()
# According to: http://clang.llvm.org/docs/AddressSanitizer.html#usage
# the following compiler flags allow us to keep -O1 on, if desired, but
# still get pretty call stacks
# set(_SANITIZER_COMPILE_OPTIONS "-g -fno-omit-frame-pointer -fno-optimize-sibling-calls")
string(TOLOWER ${SANITIZER} SANITIZER)
set(AVAILABLE_SANITIZERS "")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.7)
set(AVAILABLE_SANITIZERS address thread)
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.1)
set(AVAILABLE_SANITIZERS address thread undefined)
endif()
endif()
list(FIND AVAILABLE_SANITIZERS ${SANITIZER} _SANITIZER_FOUND)
if(${_SANITIZER_FOUND} GREATER -1)
set(_SANITIZER "-fsanitize=${SANITIZER}")
add_compile_options("-fno-omit-frame-pointer" ${_SANITIZER})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${_SANITIZER}")
else()
message(WARNING "Sanitizer '${SANITIZER}' not set, check compiler support.")
endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment