File: clang-tidy.cmake

package info (click to toggle)
freespace2 24.0.2%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid, trixie
  • size: 43,188 kB
  • sloc: cpp: 583,107; ansic: 21,729; python: 1,174; sh: 464; makefile: 248; xml: 181
file content (37 lines) | stat: -rw-r--r-- 955 bytes parent folder | download
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
31
32
33
34
35
36
37
option(ENABLE_CLANG_TIDY "Enable source code checking using clang-tidy" OFF)

find_program(
    CLANG_TIDY_EXE
    NAMES "clang-tidy"
    DOC "Path to clang-tidy executable"
)

function(enable_clang_tidy target)
    # Not enabled in this configuration
endfunction()

if(NOT ENABLE_CLANG_TIDY)
    return()
endif()

if(NOT EXISTS "${CLANG_TIDY_EXE}")
    message(SEND_ERROR "clang-tidy: Could not find clang-tidy executable (value of variable is \"${CLANG_TIDY_EXE}\".")
    return()
endif()

if(CMAKE_VERSION VERSION_LESS "3.6.0")
    message(SEND_ERROR "Clang-tidy support requires CMake 3.6")
    return()
endif()

message(STATUS "clang-tidy: Using \"${CLANG_TIDY_EXE}\"")

function(enable_clang_tidy target)
    SET(TIDY_OPTIONS "${CLANG_TIDY_EXE}")
    if(FSO_FATAL_WARNINGS)
        set(TIDY_OPTIONS "${TIDY_OPTIONS};-warnings-as-errors=*")
    endif()

    set_target_properties(${target} PROPERTIES CXX_CLANG_TIDY "${TIDY_OPTIONS}")
endfunction()