##// END OF EJS Templates
Ajout du support clang analyser. L'idée est de recompiler le projet avec ninja dans un build dédié pour effectuer l'analyse statique.
Ajout du support clang analyser. L'idée est de recompiler le projet avec ninja dans un build dédié pour effectuer l'analyse statique.

File last commit:

r10:b8cb68884afd
r11:50964fafb751
Show More
sciqlop_code_analysis.cmake
52 lines | 1.7 KiB | text/x-cmake | CMakeLexer
/ cmake / sciqlop_code_analysis.cmake
#
# sciqlop_code_analysis.cmake
# Launch code source analysis with cppcheck. Can be activated with the
# ANALYZE_CODE option.
#
# The following CACHE variables are available:
# * CPPCHECK_EXTRA_ARGS: extra arguments for cppcheck;
# * CPPCHECK_OUTPUT: path to the xml report of cppcheck.
#
# The following variables are used (must be set by the cmake file calling this
# one):
# * ANALYSIS_INPUT_DIRS: directories to analyze;
# * ANALYSIS_EXCLUDE_DIRS: directories to exclude from the analysis.
#
#
# Analyze the source code with cppcheck
#
OPTION (ANALYZE_CODE "Analyze the source code with cppcheck" ON)
IF (ANALYZE_CODE)
# Make sure cppcheck has been found, otherwise the source code can't be
# analyzed
IF (CPPCHECK_FOUND)
SET (CPPCHECK_EXTRA_ARGS --inline-suppr --xml --xml-version=2 --enable="warning,style" --force -v
CACHE STRING "Extra arguments for cppcheck")
MARK_AS_ADVANCED (CPPCHECK_EXTRA_ARGS)
SET (CPPCHECK_OUTPUT "${CMAKE_BINARY_DIR}/cppcheck-report.xml"
CACHE STRING "Output file for the cppcheck report")
MARK_AS_ADVANCED (CPPCHECK_OUTPUT)
SET (CPPCHECK_EXCLUDE_DIRS)
FOREACH (dir ${ANALYSIS_EXCLUDE_DIRS})
LIST (APPEND CPPCHECK_EXCLUDE_DIRS "-i${dir}")
ENDFOREACH ()
# Add the analyze target to launch cppcheck
ADD_CUSTOM_TARGET (analyze
COMMAND
${CPPCHECK_EXECUTABLE}
${CPPCHECK_EXTRA_ARGS}
${ANALYSIS_INPUT_DIRS}
${CPPCHECK_EXCLUDE_DIRS}
2> ${CPPCHECK_OUTPUT}
)
ELSE (CPPCHECK_FOUND)
MESSAGE (STATUS "The source code won't be analyzed - Cppcheck not found")
ENDIF (CPPCHECK_FOUND)
ENDIF (ANALYZE_CODE)