Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ament_cmake_cppcheck/cmake/ament_cppcheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions ament_cppcheck/ament_cppcheck/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=<extra_checks>', 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()
Expand Down Expand Up @@ -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)
Expand Down