diff options
author | louiz’ <louiz@louiz.org> | 2017-01-04 01:44:46 +0100 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2017-01-04 01:44:46 +0100 |
commit | 3cd0f7bbc000531411b752215469fb6ffb84b4f9 (patch) | |
tree | 783f368c008a385a0a73eeb30428784dad7cf8c4 | |
parent | 57e4f2a89f511a3f86427cfd51dd234d80383e8f (diff) | |
download | biboumi-3cd0f7bbc000531411b752215469fb6ffb84b4f9.tar.gz biboumi-3cd0f7bbc000531411b752215469fb6ffb84b4f9.tar.bz2 biboumi-3cd0f7bbc000531411b752215469fb6ffb84b4f9.tar.xz biboumi-3cd0f7bbc000531411b752215469fb6ffb84b4f9.zip |
Use fsanitize=address and undefined in debug builds if ubsan and asan are there
-rw-r--r-- | CMakeLists.txt | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f25a6ff..4cc8121 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,10 +6,26 @@ set(${PROJECT_NAME}_VERSION_MAJOR 5) set(${PROJECT_NAME}_VERSION_MINOR 0) set(${PROJECT_NAME}_VERSION_SUFFIX "~dev") +find_library(LIBASAN NAMES asan libasan.so.3 libasan.so.2 libasan.so.1) +find_library(LIBUBSAN NAMES ubsan libubsan.so.0) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -pedantic -Wall -Wextra") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage --coverage") endif() +if(LIBASAN) + message(STATUS "Libasan found.") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address") +else() + message(STATUS "Libasan NOT found.") +endif() +if(LIBUBSAN) + message(STATUS "Libubsan found.") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined") +else() + message(STATUS "Libubsan NOT found.") +endif() + # ## Look for external libraries |