blob: a1ecd56d3f2ad60174fbf3f00524b6230f183a0c (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
function (clang_detect_tool VAR NAME OPTS)
set(NAMES "")
foreach(CNT RANGE 12 22)
list(APPEND NAMES "${NAME}-${CNT}")
endforeach()
list(REVERSE NAMES)
list(APPEND NAMES ${NAME})
find_program(${VAR}
NAMES ${NAMES}
${OPTS}
)
if (NOT ${VAR})
message(WARNING "clang tool ${NAME} (${VAR}) not detected, skipping")
unset(${VAR})
return()
endif()
execute_process(
COMMAND ${${VAR}} "--version"
OUTPUT_VARIABLE _CLANG_TOOL_VERSION
RESULT_VARIABLE _CLANG_TOOL_VERSION_FAILED
)
if (_CLANG_TOOL_VERSION_FAILED)
message(WARNING "A problem was encounterd with ${${VAR}}")
message(WARNING "${_CLANG_TOOL_VERSION_FAILED}")
unset(${VAR})
return()
endif()
string(REGEX MATCH "([7-9]|[1-9][0-9])\\.[0-9]\\.[0-9]" CLANG_TOOL_VERSION
"${_CLANG_TOOL_VERSION}")
if (NOT CLANG_TOOL_VERSION)
message(WARNING "problem parsing ${NAME} version for ${${VAR}}")
unset(${VAR})
return()
endif()
set(_CLANG_TOOL_MINIMUM_VERSION "12.0.0")
if (${CLANG_TOOL_VERSION} VERSION_LESS ${_CLANG_TOOL_MINIMUM_VERSION})
message(WARNING "clang-format version ${CLANG_TOOL_VERSION} not supported")
message(WARNING "Minimum version required: ${_CLANG_TOOL_MINIMUM_VERSION}")
unset(${VAR})
return()
endif()
endfunction()
|