]> granicus.if.org Git - openjpeg/commitdiff
Add new mechanism for cppcheck
authorMathieu Malaterre <mathieu.malaterre@gmail.com>
Tue, 6 Dec 2011 16:03:05 +0000 (16:03 +0000)
committerMathieu Malaterre <mathieu.malaterre@gmail.com>
Tue, 6 Dec 2011 16:03:05 +0000 (16:03 +0000)
CMake/CTestCustom.cmake.in
CMake/FindCPPCHECK.cmake [new file with mode: 0644]
libopenjpeg/CMakeLists.txt

index a85b0510ea577e9511b96df71e2ecc7c1a99f179..60e6352832572f2e3623ac9ebaac04ac05947ec6 100644 (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"
+)
diff --git a/CMake/FindCPPCHECK.cmake b/CMake/FindCPPCHECK.cmake
new file mode 100644 (file)
index 0000000..0db297d
--- /dev/null
@@ -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
+  )
index 24ecf4091053e8d04c243858efc251f41eb65f4c..7e7da3d4641263a0285ebb1fb006113503622f51 100644 (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()