##// END OF EJS Templates
remise au norme de cppcheck (mise à jour de la version de sortie xml de 1 vers 2)
perrinel -
r10:b8cb68884afd
parent child
Show More
@@ -1,52 +1,52
1 #
1 #
2 # sciqlop_code_analysis.cmake
2 # sciqlop_code_analysis.cmake
3
3
4 # Launch code source analysis with cppcheck. Can be activated with the
4 # Launch code source analysis with cppcheck. Can be activated with the
5 # ANALYZE_CODE option.
5 # ANALYZE_CODE option.
6 #
6 #
7 # The following CACHE variables are available:
7 # The following CACHE variables are available:
8 # * CPPCHECK_EXTRA_ARGS: extra arguments for cppcheck;
8 # * CPPCHECK_EXTRA_ARGS: extra arguments for cppcheck;
9 # * CPPCHECK_OUTPUT: path to the xml report of cppcheck.
9 # * CPPCHECK_OUTPUT: path to the xml report of cppcheck.
10 #
10 #
11 # The following variables are used (must be set by the cmake file calling this
11 # The following variables are used (must be set by the cmake file calling this
12 # one):
12 # one):
13 # * ANALYSIS_INPUT_DIRS: directories to analyze;
13 # * ANALYSIS_INPUT_DIRS: directories to analyze;
14 # * ANALYSIS_EXCLUDE_DIRS: directories to exclude from the analysis.
14 # * ANALYSIS_EXCLUDE_DIRS: directories to exclude from the analysis.
15 #
15 #
16
16
17 #
17 #
18 # Analyze the source code with cppcheck
18 # Analyze the source code with cppcheck
19 #
19 #
20 OPTION (ANALYZE_CODE "Analyze the source code with cppcheck" ON)
20 OPTION (ANALYZE_CODE "Analyze the source code with cppcheck" ON)
21 IF (ANALYZE_CODE)
21 IF (ANALYZE_CODE)
22
22
23 # Make sure cppcheck has been found, otherwise the source code can't be
23 # Make sure cppcheck has been found, otherwise the source code can't be
24 # analyzed
24 # analyzed
25 IF (CPPCHECK_FOUND)
25 IF (CPPCHECK_FOUND)
26 SET (CPPCHECK_EXTRA_ARGS --inline-suppr --xml --enable=style --force -v
26 SET (CPPCHECK_EXTRA_ARGS --inline-suppr --xml --xml-version=2 --enable="warning,style" --force -v
27 CACHE STRING "Extra arguments for cppcheck")
27 CACHE STRING "Extra arguments for cppcheck")
28 MARK_AS_ADVANCED (CPPCHECK_EXTRA_ARGS)
28 MARK_AS_ADVANCED (CPPCHECK_EXTRA_ARGS)
29
29
30 SET (CPPCHECK_OUTPUT "${CMAKE_BINARY_DIR}/cppcheck-report.xml"
30 SET (CPPCHECK_OUTPUT "${CMAKE_BINARY_DIR}/cppcheck-report.xml"
31 CACHE STRING "Output file for the cppcheck report")
31 CACHE STRING "Output file for the cppcheck report")
32 MARK_AS_ADVANCED (CPPCHECK_OUTPUT)
32 MARK_AS_ADVANCED (CPPCHECK_OUTPUT)
33
33
34 SET (CPPCHECK_EXCLUDE_DIRS)
34 SET (CPPCHECK_EXCLUDE_DIRS)
35 FOREACH (dir ${ANALYSIS_EXCLUDE_DIRS})
35 FOREACH (dir ${ANALYSIS_EXCLUDE_DIRS})
36 LIST (APPEND CPPCHECK_EXCLUDE_DIRS "-i${dir}")
36 LIST (APPEND CPPCHECK_EXCLUDE_DIRS "-i${dir}")
37 ENDFOREACH ()
37 ENDFOREACH ()
38
38
39 # Add the analyze target to launch cppcheck
39 # Add the analyze target to launch cppcheck
40 ADD_CUSTOM_TARGET (analyze
40 ADD_CUSTOM_TARGET (analyze
41 COMMAND
41 COMMAND
42 ${CPPCHECK_EXECUTABLE}
42 ${CPPCHECK_EXECUTABLE}
43 ${CPPCHECK_EXTRA_ARGS}
43 ${CPPCHECK_EXTRA_ARGS}
44 ${ANALYSIS_INPUT_DIRS}
44 ${ANALYSIS_INPUT_DIRS}
45 ${CPPCHECK_EXCLUDE_DIRS}
45 ${CPPCHECK_EXCLUDE_DIRS}
46 2> ${CPPCHECK_OUTPUT}
46 2> ${CPPCHECK_OUTPUT}
47 )
47 )
48
48
49 ELSE (CPPCHECK_FOUND)
49 ELSE (CPPCHECK_FOUND)
50 MESSAGE (STATUS "The source code won't be analyzed - Cppcheck not found")
50 MESSAGE (STATUS "The source code won't be analyzed - Cppcheck not found")
51 ENDIF (CPPCHECK_FOUND)
51 ENDIF (CPPCHECK_FOUND)
52 ENDIF (ANALYZE_CODE)
52 ENDIF (ANALYZE_CODE)
General Comments 0
You need to be logged in to leave comments. Login now