CMAKE: added sanitizers

master
Martin Gerhardy 2018-10-13 11:59:13 +02:00
parent 4c5caec28f
commit 9d268e1d16
4 changed files with 45 additions and 0 deletions

4
.clang-tidy Normal file
View File

@ -0,0 +1,4 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,modernizer*,-clang-analyzer-alpha*'
...

View File

@ -29,6 +29,9 @@ option(USE_CCACHE "Use ccache" ON)
option(USE_GPROF "Use gprof - will become slow" OFF)
option(USE_GCOV "Use gcov - will become slow" OFF)
option(USE_DOXYGEN_CHECK "Use -Wdocumentation if available" OFF)
option(USE_LINK_WHAT_YOU_USE "Enable link-what-you-use" OFF)
option(USE_CPPCHECK "Enable cppcheck" OFF)
option(USE_CLANG_TIDY "Enable Clang Tidy" OFF)
set(DEBUGGER "gdb" CACHE STRING "Which debugger should be used")
set_property(CACHE DEBUGGER PROPERTY STRINGS gdb lldb)
set(SERVER_HOST "localhost" CACHE STRING "Host where the server is running on")
@ -104,11 +107,37 @@ if (CCACHE)
message(STATUS "Using ccache")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
set(ENV{CCACHE_CPP2} "yes")
add_compile_options(-Qunused-arguments)
endif()
endif()
else()
message(STATUS "ccache not found")
endif()
if (USE_LINK_WHAT_YOU_USE)
set(CMAKE_LINK_WHAT_YOU_USE ON)
endif()
if (USE_CLANG_TIDY)
find_host_program(CLANG_TIDY_EXECUTABLE NAMES clang-tidy clang-tidy-3.8)
if (CLANG_TIDY_EXECUTABLE)
set(CLANG_TIDY_OPTS ${CLANG_TIDY_EXECUTABLE})
set(CMAKE_C_CLANG_TIDY "${CLANG_TIDY_OPTS}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_OPTS}")
endif()
endif()
if (USE_CPPCHECK)
find_host_program(CPPCHECK_EXECUTABLE NAMES cppcheck)
if (CPPCHECK_EXECUTABLE)
set(CPPCHECK_OPTS ${CPPCHECK_EXECUTABLE} "--enable=all")
set(CMAKE_C_CPPCHECK "${CLANG_TIDY_OPTS}")
set(CMAKE_CXX_CPPCHECK "${CLANG_TIDY_OPTS}")
endif()
endif()
find_host_program(GDB_EXECUTABLE NAMES ${GDB_BINARY} gdb)
find_host_program(LLDB_EXECUTABLE NAMES ${LLDB_BINARY} lldb)
find_host_program(GIT_EXECUTABLE NAMES ${GIT_BINARY} git)

6
contrib/.clang-tidy Normal file
View File

@ -0,0 +1,6 @@
---
# We want to disable all checks for 3rd party code. However, clang-tidy will
# assume we did not configure it correctly. Just add one check that will never
# be found.
Checks: '-*,llvm-twine-local'
...

View File

@ -0,0 +1,6 @@
---
# We want to disable all checks for 3rd party code. However, clang-tidy will
# assume we did not configure it correctly. Just add one check that will never
# be found.
Checks: '-*,llvm-twine-local'
...