From e08e905350821705353fcfc6bd561eb1a52ff895 Mon Sep 17 00:00:00 2001 From: Karsten Knese Date: Tue, 12 Feb 2019 12:02:27 -0800 Subject: [PATCH] use globally defined varible for cppcheck include dirs (#125) * use globally defined varible for cppcheck include dirs Signed-off-by: Karsten Knese * update docblock Signed-off-by: Karsten Knese period --- .../cmake/ament_cmake_cppcheck_lint_hook.cmake | 5 +++++ ament_cmake_cppcheck/cmake/ament_cppcheck.cmake | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ament_cmake_cppcheck/cmake/ament_cmake_cppcheck_lint_hook.cmake b/ament_cmake_cppcheck/cmake/ament_cmake_cppcheck_lint_hook.cmake index d8a90ae3..ca8f767a 100644 --- a/ament_cmake_cppcheck/cmake/ament_cmake_cppcheck_lint_hook.cmake +++ b/ament_cmake_cppcheck/cmake/ament_cmake_cppcheck_lint_hook.cmake @@ -29,6 +29,10 @@ if(_source_files) # Get include paths for added targets set(_all_include_dirs "") + if(DEFINED ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS) + list(APPEND _all_include_dirs ${ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS}) + endif() + # BUILDSYSTEM_TARGETS only supported in CMake >= 3.7 if(NOT CMAKE_VERSION VERSION_LESS "3.7.0") get_directory_property(_build_targets DIRECTORY ${CMAKE_SOURCE_DIR} BUILDSYSTEM_TARGETS) @@ -59,5 +63,6 @@ if(_source_files) endforeach() endif() + message(STATUS "Configured cppcheck include dirs: ${_all_include_dirs}") ament_cppcheck(INCLUDE_DIRS ${_all_include_dirs}) endif() diff --git a/ament_cmake_cppcheck/cmake/ament_cppcheck.cmake b/ament_cmake_cppcheck/cmake/ament_cppcheck.cmake index e3ea7b45..201dd909 100644 --- a/ament_cmake_cppcheck/cmake/ament_cppcheck.cmake +++ b/ament_cmake_cppcheck/cmake/ament_cppcheck.cmake @@ -15,6 +15,10 @@ # # Add a test to perform static code analysis with cppcheck. # +# The include dirs for cppcheck to consider can either be set by the function +# parameter 'INCLUDE_DIRS` or by a global variable called +# 'ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS'. +# # :param TESTNAME: the name of the test, default: "cppcheck" # :type TESTNAME: string # :param LANGUAGE: the language argument for cppcheck, either 'c' or 'c++'