-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindClangTidy.cmake
26 lines (21 loc) · 952 Bytes
/
FindClangTidy.cmake
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
#.rst:
# FindClangTidy
# -------------
# Finds clang-tidy and sets it up to run along with the compiler for C and CXX.
find_program(CLANG_TIDY_EXECUTABLE clang-tidy)
if(CLANG_TIDY_EXECUTABLE)
execute_process(COMMAND "${CLANG_TIDY_EXECUTABLE}" --version
OUTPUT_VARIABLE CLANG_TIDY_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "[^\n]* version [^\n]*" CLANG_TIDY_VERSION "${CLANG_TIDY_VERSION}")
string(REGEX REPLACE ".* version (.*)" "\\1" CLANG_TIDY_VERSION "${CLANG_TIDY_VERSION}")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ClangTidy REQUIRED_VARS CLANG_TIDY_EXECUTABLE
VERSION_VAR CLANG_TIDY_VERSION)
if(CLANGTIDY_FOUND)
# Supports Unix Makefiles and Ninja
set(CMAKE_C_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}" PARENT_SCOPE)
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}" PARENT_SCOPE)
endif()
mark_as_advanced(CLANG_TIDY_EXECUTABLE)