-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCppCheck.cmake
66 lines (60 loc) · 2.84 KB
/
CppCheck.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
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
################################################################################
#
# \file CppCheck.cmake
# \copyright 2012-2015 J. Bakosi,
# 2016-2018 Los Alamos National Security, LLC.,
# 2019-2021 Triad National Security, LLC.
# All rights reserved. See the LICENSE file for details.
# \brief Setup target for code coverage analysis
#
################################################################################
find_program( CPPCHECK cppcheck )
find_program( CPPCHECK_HTMLREPORT cppcheck-htmlreport )
if(CPPCHECK AND CPPCHECK_HTMLREPORT)
ADD_CUSTOM_TARGET(cppcheck
# Run cppcheck static analysis
COMMAND ${CPPCHECK} --inline-suppr --enable=all --force
--error-exitcode=1 -j${PROCESSOR_COUNT}
-I${PROJECT_SOURCE_DIR}/Base
-I${PROJECT_SOURCE_DIR}/Control
-I${PROJECT_SOURCE_DIR}/NoWarning
-I${PROJECT_BINARY_DIR}/Main
${CMAKE_CURRENT_SOURCE_DIR}
# Set work directory for target
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
# Echo what is being done
COMMENT "Quinoa cppcheck static analysis report"
VERBATIM USES_TERMINAL
)
# Output code coverage target enabled
message(STATUS "Enabling cppcheck static analysis target 'cppcheck'")
find_program( FILEFIND find )
find_program( SED sed )
if(FILEFIND AND SED)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/doc/cppcheck)
string(REGEX REPLACE "Quinoa_v(.*)-(.*)-g(.*)" "\\3" SHA1 ${GIT_SHA1})
ADD_CUSTOM_TARGET(cppcheck-xml
# Run cppcheck static analysis
COMMAND ${CPPCHECK} --inline-suppr --enable=all --force
--xml --xml-version=2 -j${PROCESSOR_COUNT}
-I${PROJECT_SOURCE_DIR}/Base
-I${PROJECT_SOURCE_DIR}/Control
-I${PROJECT_SOURCE_DIR}/NoWarning
-I${PROJECT_BINARY_DIR}/Main
${CMAKE_CURRENT_SOURCE_DIR}
2> doc/cppcheck/cppcheck-report.xml
# Generate html output
COMMAND ${CPPCHECK_HTMLREPORT} --file=doc/cppcheck/cppcheck-report.xml
--report-dir=doc/cppcheck --source-dir=.
# Customize page headers in generated html
COMMAND ${FILEFIND} doc/cppcheck -type f -exec ${SED} -i "s/project name/<a href=https:\\/\\/github.com\\/quinoacomputing\\/quinoa\\/commit\\/${SHA1}>${GIT_SHA1}<\\/a>/g" {} +
# Set work directory for target
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
# Echo what is being done
COMMENT "Quinoa cppcheck-xml static analysis report"
VERBATIM USES_TERMINAL
)
# Output code coverage target enabled
message(STATUS "Enabling cppcheck static analysis target 'cppcheck-xml', report at ${CMAKE_BINARY_DIR}/doc/cppcheck/index.html")
endif()
endif()