Repository navigation
Expand file tree
/
Copy pathRunLinter.cmake
More file actions
71 lines (56 loc) · 1.74 KB
/
Copy pathRunLinter.cmake
File metadata and controls
71 lines (56 loc) · 1.74 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# /RunLinter.cmake
#
# A wrapper around linters which can treat a
# positive exit status as a non-error.
#
# See /LICENCE.md for Copyright information
set (EXECUTABLE "" CACHE STRING "")
set (SOURCES "" CACHE STRING "")
set (OPTIONS "" CACHE STRING "")
set (VERBOSE "" CACHE STRING "")
set (WARN_ONLY "" CACHE STRING "")
set (SOURCES_LAST "" CACHE STRING "")
if (NOT EXECUTABLE)
message (FATAL_ERROR "EXECUTABLE not specified. "
"This is a bug in CMakeLinter.cmake")
endif ()
if (NOT SOURCES)
message (FATAL_ERROR "SOURCES not specified. "
"This is a bug in CMakeLinter.cmake")
endif ()
# Convert from "`" as a delimiter to ";"
string (REPLACE "`" ";" OPTIONS "${OPTIONS}")
string (REPLACE "`" ";" SOURCES "${SOURCES}")
if (NOT SOURCES_LAST)
set (LINTER_COMMAND_LINE
"${EXECUTABLE}"
${SOURCES}
${OPTIONS})
else ()
set (LINTER_COMMAND_LINE
"${EXECUTABLE}"
${OPTIONS}
${SOURCES})
endif ()
string (REPLACE ";" " " LINTER_PRINTED_COMMAND_LINE
"${LINTER_COMMAND_LINE}")
if (VERBOSE)
message (STATUS "${LINTER_PRINTED_COMMAND_LINE}")
endif ()
execute_process (COMMAND
${LINTER_COMMAND_LINE}
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE OUTPUT
ERROR_VARIABLE ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
if (NOT RESULT EQUAL 0)
message ("${OUTPUT}")
message ("${ERROR}")
if (NOT WARN_ONLY)
set (MESSAGE
"${LINTER_PRINTED_COMMAND_LINE} found issues with ${SOURCES} ")
set (MESSAGE "${MESSAGE} exiting with ${RESULT}")
message (FATAL_ERROR "${MESSAGE}")
endif ()
endif ()