summaryrefslogtreecommitdiff
path: root/cmake/CodeAnalysis.cmake
blob: 7bba40d2353c2446b85c8ec7ccef217a765e1e18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
option(ENABLE_CPPCHECK "Enable static analysis with Cppcheck" OFF)
if(ENABLE_CPPCHECK)
  find_program(CPPCHECK_EXE cppcheck)
  mark_as_advanced(CPPCHECK_EXE) # Don't show in CMake UIs
  if(CPPCHECK_EXE)
    set(CMAKE_CXX_CPPCHECK
        ${CPPCHECK_EXE}
        --suppressions-list=${CMAKE_SOURCE_DIR}/misc/cppcheck-suppressions.txt
        --inline-suppr
        -q
        --enable=all
        --force
        --std=c++17
        -I ${CMAKE_SOURCE_DIR}
        --template="cppcheck: warning: {id}:{file}:{line}: {message}"
        -i src/third_party)
  else()
    message(WARNING "Cppcheck requested but executable not found")
  endif()
endif()

option(ENABLE_CLANG_TIDY "Enable static analysis with Clang-Tidy" OFF)
if(ENABLE_CLANG_TIDY)
  find_program(CLANGTIDY clang-tidy)
  if(CLANGTIDY)
    set(CMAKE_CXX_CLANG_TIDY ${CLANGTIDY})
  else()
    message(SEND_ERROR "Clang-Tidy requested but executable not found")
  endif()
endif()