diff --git a/ament_cmake_cppcheck/cmake/ament_cppcheck.cmake b/ament_cmake_cppcheck/cmake/ament_cppcheck.cmake index cc66f416..c4880ec2 100644 --- a/ament_cmake_cppcheck/cmake/ament_cppcheck.cmake +++ b/ament_cmake_cppcheck/cmake/ament_cppcheck.cmake @@ -35,7 +35,7 @@ # @public # function(ament_cppcheck) - cmake_parse_arguments(ARG "" "LANGUAGE;TESTNAME" "EXCLUDE;LIBRARIES;INCLUDE_DIRS" ${ARGN}) + cmake_parse_arguments(ARG "" "ENABLE_EXTRA_CHECKS;LANGUAGE;TESTNAME" "EXCLUDE;LIBRARIES;INCLUDE_DIRS" ${ARGN}) if(NOT ARG_TESTNAME) set(ARG_TESTNAME "cppcheck") endif() @@ -61,6 +61,10 @@ function(ament_cppcheck) if(ARG_INCLUDE_DIRS) list(APPEND cmd "--include_dirs" "${ARG_INCLUDE_DIRS}") endif() + if(ARG_ENABLE_EXTRA_CHECKS) + string(TOLOWER ${ARG_ENABLE_EXTRA_CHECKS} ARG_ENABLE_EXTRA_CHECKS) + list(APPEND cmd "--enable-extra-checks" "${ARG_ENABLE_EXTRA_CHECKS}") + endif() file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_cppcheck") ament_add_test( diff --git a/ament_cppcheck/ament_cppcheck/main.py b/ament_cppcheck/ament_cppcheck/main.py index 83c78744..2057e1d1 100755 --- a/ament_cppcheck/ament_cppcheck/main.py +++ b/ament_cppcheck/ament_cppcheck/main.py @@ -93,6 +93,10 @@ def main(argv=sys.argv[1:]): '--cppcheck-version', action='store_true', help='Get the cppcheck version, print it, and then exit.') + parser.add_argument( + '--enable-extra-checks', + help="Passed to cppcheck as '--enable=', and add extra checks to cppcheck " + "as the given extra_checks (e.g. 'all', 'warning', 'style').") args = parser.parse_args(argv) cppcheck_bin = find_cppcheck_executable() @@ -161,6 +165,8 @@ def main(argv=sys.argv[1:]): cmd.extend(['--suppress=*:' + exclude]) if jobs: cmd.extend(['-j', '%d' % jobs]) + if args.enable_extra_checks: + cmd.extend(['--enable={0}'.format(args.enable_extra_checks)]) cmd.extend(files) try: p = subprocess.Popen(cmd, stderr=subprocess.PIPE)