From 41855e444a57f40ed26b3ef63bd3756b29c8e699 Mon Sep 17 00:00:00 2001 From: Timo Lotterbach Date: Fri, 15 Mar 2013 16:07:49 +0100 Subject: [PATCH] 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 --- CMakeLists.txt | 11 +++++++++++ cmake/modules/DefaultSettings.txt | 14 ++++++++++++++ 2 files changed, 25 insertions(+) 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 ${CPPCHECK_CONFIG_STRING}") + set(CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT}; cppcheck ${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) + -- 2.7.4