summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Malaterre <mathieu.malaterre@gmail.com>2011-12-06 16:03:05 +0000
committerMathieu Malaterre <mathieu.malaterre@gmail.com>2011-12-06 16:03:05 +0000
commitbfe8b81d187aa49662f3700575c9c433f0c667df (patch)
treeafd43dfda75f4ad73f617e1e43ab5bb5436e85d5
parentec71c19be7c8af4c2a4db0f7b39d0cc658d06435 (diff)
Add new mechanism for cppcheck
-rw-r--r--CMake/CTestCustom.cmake.in26
-rw-r--r--CMake/FindCPPCHECK.cmake16
-rw-r--r--libopenjpeg/CMakeLists.txt17
3 files changed, 46 insertions, 13 deletions
diff --git a/CMake/CTestCustom.cmake.in b/CMake/CTestCustom.cmake.in
index a85b0510..60e63528 100644
--- a/CMake/CTestCustom.cmake.in
+++ b/CMake/CTestCustom.cmake.in
@@ -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"
+)
diff --git a/CMake/FindCPPCHECK.cmake b/CMake/FindCPPCHECK.cmake
new file mode 100644
index 00000000..0db297db
--- /dev/null
+++ b/CMake/FindCPPCHECK.cmake
@@ -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
+ )
diff --git a/libopenjpeg/CMakeLists.txt b/libopenjpeg/CMakeLists.txt
index 24ecf409..7e7da3d4 100644
--- a/libopenjpeg/CMakeLists.txt
+++ b/libopenjpeg/CMakeLists.txt
@@ -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()