Skip to content

Commit

Permalink
Adding support for ignore files. Refs #4368.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfpeterson committed Dec 29, 2011
1 parent 979f043 commit ac72e05
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Code/Mantid/Build/CMake/FindCppcheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,18 @@ mark_as_advanced(CPPCHECK_EXECUTABLE)
set ( CPPCHECK_ARGS "--enable=all" CACHE STRING "Arguments for running cppcheck" )
set ( CPPCHECK_GENERATE_XML OFF CACHE BOOL "Generate xml output files from cppcheck" )

function(add_cppcheck _name)
function(add_cppcheck _name) # additional arguments are files to ignore
if(NOT TARGET ${_name})
message(FATAL_ERROR
"add_cppcheck given a target name that does not exist: '${_name}' !")
endif()

set (_cppcheck_ignores)
foreach (f ${ARGN})
list ( APPEND _cppcheck_ignores "-i" ${CMAKE_CURRENT_SOURCE_DIR}/${f} )
endforeach()
message ( status " IGNORES ${_cppcheck_ignores}")

if(CPPCHECK_EXECUTABLE)
get_target_property(_cppcheck_sources "${_name}" SOURCES)
set(_files)
Expand All @@ -74,15 +80,18 @@ function(add_cppcheck _name)
endif()
endforeach()

set ( _cppcheck_args )
list ( APPEND _cppcheck_args ${CPPCHECK_TEMPLATE_ARG} ${CPPCHECK_ARGS} ${_cppcheck_ignores} )

if (CPPCHECK_GENERATE_XML )
add_custom_target( cppcheck_${_name}
COMMAND ${CPPCHECK_EXECUTABLE} ${CPPCHECK_TEMPLATE_ARG} ${CPPCHECK_ARGS} --xml --xml-version=2 ${_files} 2> ${CMAKE_BINARY_DIR}/cppcheck-${_name}.xml
COMMAND ${CPPCHECK_EXECUTABLE} ${_cppcheck_args} --xml --xml-version=2 ${_files} 2> ${CMAKE_BINARY_DIR}/cppcheck-${_name}.xml
DEPENDS ${_files}
COMMENT "cppcheck_${_name}: Running cppcheck to generate cppcheck-${_name}.xml"
)
else (CPPCHECK_GENERATE_XML )
add_custom_target( cppcheck_${_name}
COMMAND ${CPPCHECK_EXECUTABLE} ${CPPCHECK_TEMPLATE_ARG} ${CPPCHECK_ARGS} ${_files}
COMMAND ${CPPCHECK_EXECUTABLE} ${_cppcheck_args} ${_files}
DEPENDS ${_files}
COMMENT "cppcheck_${_name}: Running cppcheck on ${_name} source files"
)
Expand Down

0 comments on commit ac72e05

Please sign in to comment.