summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Lotterbach <timo.lotterbach@bmw-carit.de>2013-03-15 16:07:49 +0100
committerTimo Lotterbach <timo.lotterbach@bmw-carit.de>2013-03-18 09:56:55 +0100
commit41855e444a57f40ed26b3ef63bd3756b29c8e699 (patch)
treeda328f7f3da20ed1321b11e4373eea3cab8b5ee8
parent4b28966fb4bc4d1261271b426d5765a58c412393 (diff)
downloadlayer_management-41855e444a57f40ed26b3ef63bd3756b29c8e699.tar.gz
CMake: added 'make cppcheck' build target and WITH_CPPCHECK build flag
- support for 'make cppcheck' to run configured tests - enable WITH_CPPCHECK to run cppcheck for each compiled file Signed-off-by: Timo Lotterbach <timo.lotterbach@bmw-carit.de>
-rw-r--r--CMakeLists.txt11
-rw-r--r--cmake/modules/DefaultSettings.txt14
2 files changed, 25 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index da4bd73..0664600 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,6 +68,16 @@ else (WITH_DOCUMENTATION)
endif (WITH_DOCUMENTATION)
#===========================================================================================================
+build_flag (WITH_CPPCHECK "Run cppcheck during build (requires cppcheck)" OFF)
+# add build target 'cppcheck' to run pre-defined configuration of cppcheck
+#===========================================================================================================
+if (WITH_CPPCHECK)
+ set(CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}; cppcheck <SOURCE> ${CPPCHECK_CONFIG_STRING}")
+ set(CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT}; cppcheck <SOURCE> ${CPPCHECK_CONFIG_STRING}")
+endif (WITH_CPPCHECK)
+add_custom_target(cppcheck COMMAND cppcheck ${CMAKE_SOURCE_DIR}/LayerManager*/ ${CPPCHECK_CONFIG})
+
+#===========================================================================================================
build_flag (WITH_TESTS "Build unit test binaries for all enabled components" OFF)
#===========================================================================================================
if (WITH_TESTS)
@@ -288,3 +298,4 @@ endif (WITH_CONTROL_LIB)
# store used build configuration
#===========================================================================================================
add_subdirectory_once(config)
+
diff --git a/cmake/modules/DefaultSettings.txt b/cmake/modules/DefaultSettings.txt
index 8b2945a..0c342a9 100644
--- a/cmake/modules/DefaultSettings.txt
+++ b/cmake/modules/DefaultSettings.txt
@@ -86,3 +86,17 @@ set (STATICALLY_LINKED_PLUGINS "" CACHE INTERNAL "list of static plugins")
set (BUILD_FLAG_LIST "" CACHE INTERNAL "list of build flag names")
set (BUILD_FLAG_ARRAY "" CACHE INTERNAL "array of build flags for logging")
+
+#==============================================================================
+# cppcheck configuration
+#==============================================================================
+set (CPPCHECK_CONFIG
+ --quiet
+ --enable=performance,portability
+ --template='{file}:{line}: warning: {message} [{severity}]'
+)
+
+FOREACH (ARG ${CPPCHECK_CONFIG})
+ set (CPPCHECK_CONFIG_STRING "${CPPCHECK_CONFIG_STRING} ${ARG}")
+ENDFOREACH(ARG)
+