1
1
#
2
- # Copyright (C) 2018-2020 by George Cave - [email protected]
2
+ # Copyright (C) 2018-2023 by George Cave - [email protected]
3
3
#
4
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
5
5
# use this file except in compliance with the License. You may obtain a copy of
@@ -21,6 +21,9 @@ option(CPPCHECK "Turns on cppcheck processing if it is found." OFF)
21
21
# as the options set.
22
22
macro (clang_tidy)
23
23
if (CLANG_TIDY AND CLANG_TIDY_EXE)
24
+ set (CMAKE_C_CLANG_TIDY
25
+ ${CLANG_TIDY_EXE} ${ARGN}
26
+ CACHE STRING "" FORCE)
24
27
set (CMAKE_CXX_CLANG_TIDY
25
28
${CLANG_TIDY_EXE} ${ARGN}
26
29
CACHE STRING "" FORCE)
@@ -31,6 +34,9 @@ endmacro()
31
34
# used as the options set.
32
35
macro (include_what_you_use)
33
36
if (IWYU AND IWYU_EXE)
37
+ set (CMAKE_C_INCLUDE_WHAT_YOU_USE
38
+ ${IWYU_EXE} ${ARGN}
39
+ CACHE STRING "" FORCE)
34
40
set (CMAKE_CXX_INCLUDE_WHAT_YOU_USE
35
41
${IWYU_EXE} ${ARGN}
36
42
CACHE STRING "" FORCE)
@@ -41,6 +47,9 @@ endmacro()
41
47
# options set.
42
48
macro (cppcheck)
43
49
if (CPPCHECK AND CPPCHECK_EXE)
50
+ set (CMAKE_C_CPPCHECK
51
+ ${CPPCHECK_EXE} ${ARGN}
52
+ CACHE STRING "" FORCE)
44
53
set (CMAKE_CXX_CPPCHECK
45
54
${CPPCHECK_EXE} ${ARGN}
46
55
CACHE STRING "" FORCE)
@@ -53,17 +62,26 @@ if(CLANG_TIDY_EXE)
53
62
message (STATUS "clang-tidy found: ${CLANG_TIDY_EXE} " )
54
63
if (NOT CLANG_TIDY)
55
64
message (STATUS "clang-tidy NOT ENABLED via 'CLANG_TIDY' variable!" )
65
+ set (CMAKE_C_CLANG_TIDY
66
+ ""
67
+ CACHE STRING "" FORCE) # delete it
56
68
set (CMAKE_CXX_CLANG_TIDY
57
69
""
58
70
CACHE STRING "" FORCE) # delete it
59
71
endif ()
60
72
elseif (CLANG_TIDY)
61
73
message (SEND_ERROR "Cannot enable clang-tidy, as executable not found!" )
74
+ set (CMAKE_C_CLANG_TIDY
75
+ ""
76
+ CACHE STRING "" FORCE) # delete it
62
77
set (CMAKE_CXX_CLANG_TIDY
63
78
""
64
79
CACHE STRING "" FORCE) # delete it
65
80
else ()
66
81
message (STATUS "clang-tidy not found!" )
82
+ set (CMAKE_C_CLANG_TIDY
83
+ ""
84
+ CACHE STRING "" FORCE) # delete it
67
85
set (CMAKE_CXX_CLANG_TIDY
68
86
""
69
87
CACHE STRING "" FORCE) # delete it
@@ -75,18 +93,27 @@ if(IWYU_EXE)
75
93
message (STATUS "include-what-you-use found: ${IWYU_EXE} " )
76
94
if (NOT IWYU)
77
95
message (STATUS "include-what-you-use NOT ENABLED via 'IWYU' variable!" )
96
+ set (CMAKE_C_INCLUDE_WHAT_YOU_USE
97
+ ""
98
+ CACHE STRING "" FORCE) # delete it
78
99
set (CMAKE_CXX_INCLUDE_WHAT_YOU_USE
79
100
""
80
101
CACHE STRING "" FORCE) # delete it
81
102
endif ()
82
103
elseif (IWYU)
83
104
message (
84
105
SEND_ERROR "Cannot enable include-what-you-use, as executable not found!" )
106
+ set (CMAKE_C_INCLUDE_WHAT_YOU_USE
107
+ ""
108
+ CACHE STRING "" FORCE) # delete it
85
109
set (CMAKE_CXX_INCLUDE_WHAT_YOU_USE
86
110
""
87
111
CACHE STRING "" FORCE) # delete it
88
112
else ()
89
113
message (STATUS "include-what-you-use not found!" )
114
+ set (CMAKE_C_INCLUDE_WHAT_YOU_USE
115
+ ""
116
+ CACHE STRING "" FORCE) # delete it
90
117
set (CMAKE_CXX_INCLUDE_WHAT_YOU_USE
91
118
""
92
119
CACHE STRING "" FORCE) # delete it
@@ -97,23 +124,35 @@ mark_as_advanced(FORCE CPPCHECK_EXE)
97
124
if (CPPCHECK_EXE)
98
125
message (STATUS "cppcheck found: ${CPPCHECK_EXE} " )
99
126
if (CPPECHECK)
127
+ set (CMAKE_C_CPPCHECK
128
+ "${CPPCHECK_EXE} ;--enable=warning,performance,portability,missingInclude;--template=\" [{severity}][{id}] {message} {callstack} \( On {file}:{line}\)\" ;--suppress=missingIncludeSystem;--quiet;--verbose;--force"
129
+ )
100
130
set (CMAKE_CXX_CPPCHECK
101
131
"${CPPCHECK_EXE} ;--enable=warning,performance,portability,missingInclude;--template=\" [{severity}][{id}] {message} {callstack} \( On {file}:{line}\)\" ;--suppress=missingIncludeSystem;--quiet;--verbose;--force"
102
132
)
103
133
endif ()
104
134
if (NOT CPPCHECK)
105
135
message (STATUS "cppcheck NOT ENABLED via 'CPPCHECK' variable!" )
136
+ set (CMAKE_C_CPPCHECK
137
+ ""
138
+ CACHE STRING "" FORCE) # delete it
106
139
set (CMAKE_CXX_CPPCHECK
107
140
""
108
141
CACHE STRING "" FORCE) # delete it
109
142
endif ()
110
143
elseif (CPPCHECK)
111
144
message (SEND_ERROR "Cannot enable cppcheck, as executable not found!" )
145
+ set (CMAKE_C_CPPCHECK
146
+ ""
147
+ CACHE STRING "" FORCE) # delete it
112
148
set (CMAKE_CXX_CPPCHECK
113
149
""
114
150
CACHE STRING "" FORCE) # delete it
115
151
else ()
116
152
message (STATUS "cppcheck not found!" )
153
+ set (CMAKE_C_CPPCHECK
154
+ ""
155
+ CACHE STRING "" FORCE) # delete it
117
156
set (CMAKE_CXX_CPPCHECK
118
157
""
119
158
CACHE STRING "" FORCE) # delete it
0 commit comments