Add new mechanism for cppcheck

This commit is contained in:
Mathieu Malaterre 2011-12-06 16:03:05 +00:00
parent ec71c19be7
commit bfe8b81d18
3 changed files with 46 additions and 13 deletions

View File

@ -1,14 +1,3 @@
#
# Note that the ITK/CMakeLists.txt file configures this file
#
# CMake/CTestCustom.cmake.in
#
# to this file
#
# ${ITK_BINARY_DIR}/CTestCustom.cmake
#
#----------------------------------------------------------------------
#
# For further details regarding this file,
# see http://www.cmake.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest
#
@ -18,8 +7,8 @@
#----------------------------------------------------------------------
SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000)
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000)
SET(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
SET(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000)
SET(CTEST_CUSTOM_COVERAGE_EXCLUDE
${CTEST_CUSTOM_COVERAGE_EXCLUDE}
@ -37,3 +26,14 @@ SET(CTEST_CUSTOM_WARNING_EXCEPTION
# Suppress warning caused by intentional messages about deprecation
".*warning,.* is deprecated"
)
# Custom mechanism to catch cppcheck reports:
#set(CTEST_CUSTOM_ERROR_MATCH
# "error"
#)
# don't ask
SET(CTEST_CUSTOM_WARNING_MATCH
"error"
)

16
CMake/FindCPPCHECK.cmake Normal file
View File

@ -0,0 +1,16 @@
# cppcheck
#
# Copyright (c) 2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
FIND_PROGRAM(CPPCHECK_EXECUTABLE
cppcheck
)
MARK_AS_ADVANCED(
CPPCHECK_EXECUTABLE
)

View File

@ -63,3 +63,20 @@ INSTALL(CODE
INSTALL(
FILES ${OPENJPEG_SOURCE_DIR}/doc/man/man3/libopenjpeg.3
DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man3)
# Experimental option; let's how cppcheck performs
# Implementation details:
# I could not figure out how to easily upload a file to CDash. Instead simply
# pretend cppcheck is part of the Build step. Technically cppcheck can even
# output gcc formatted error/warning report
# Another implementation detail: I could not redirect error to the error
# catching mechanism something is busted in cmake 2.8.5, I had to use the
# warning regex to catch them.
if(OPENJPEG_CPPCHECK)
find_package(CPPCHECK REQUIRED)
foreach(f ${OPENJPEG_SRCS})
# cppcheck complains about too many configuration, pretend to be WIN32:
add_custom_command(TARGET ${OPENJPEG_LIBRARY_NAME}
COMMAND ${CPPCHECK_EXECUTABLE} -DWIN32 ${f})
endforeach()
endif()