Conversation
ament_cmake_cppcheck/cmake/ament_cmake_cppcheck_lint_hook.cmake
Outdated
Show resolved
Hide resolved
Specifically, passing the parent directories of all source files since a typical include for a C/C++ header are located in a subdirectory named after the package or library.
Co-Authored-By: jacobperron <jacob@openrobotics.org>
fce39dd to
c3d0e8d
Compare
|
I've updated the PR to use |
ament_cmake_cppcheck/cmake/ament_cmake_cppcheck_lint_hook.cmake
Outdated
Show resolved
Hide resolved
ament_cmake_cppcheck/cmake/ament_cmake_cppcheck_lint_hook.cmake
Outdated
Show resolved
Hide resolved
cppcheck can take significantly longer to execute when passing include directories.
|
A couple issues I've identified with this approach:
Thoughts? |
…being tested This eliminates the need for a longer test timeout and avoids cppcheck from testing external files. Reverted prior changes accordingly.
|
Attempt to resolve timeout issue and errors from external packages by only including headers from the package being tested. |
|
Ready for another round of review. Passing include directories to cppcheck uncovered a potential issue in rcl (fixed in ros2/rcl#371). It's possible there will be more uncovered issues. |
|
CI is good. The one cppcheck error is handled by ros2/rcl#371. |
ament_cmake_cppcheck/cmake/ament_cmake_cppcheck_lint_hook.cmake
Outdated
Show resolved
Hide resolved
| PROPERTY INCLUDE_DIRECTORIES | ||
| ) | ||
|
|
||
| # Only append include directories that are from the package being tested |
There was a problem hiding this comment.
I'm seeing a similar cppcheck complaint in rmw_connext and rmw_opensplice where they use a macro RMW_CHECK_TYPE_IDENTIFIERS_MATCH that is defined rmw.
Any way to tell cppcheck where to look for macros without checking external files?
| # Only append include directories that are from the package being tested | ||
| # This accomplishes two things: | ||
| # 1. Reduces execution time (less include directories to search) | ||
| # 2. cppcheck will not check for errors in external packages |
There was a problem hiding this comment.
This fails on Windows in this case: ros2/ros2#942.
There was a problem hiding this comment.
I don't understand the case that's failing. From the referenced ticket, it looks like the failures are due to headers from external packages not being passed to cppcheck (which is the intended behavior). For this case, we have ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS that can be set (introduced in #125).
There was a problem hiding this comment.
Without the proper include directories cppcheck warns for unknown macros.
ros2/rclpy#577 sets an additional include dir.
Specifically, passing the parent directories of all source files since a typical include
for a C/C++ header are located in a subdirectory named after the package or library.
Resolves #116
Test CI with cppcheck v1.86 (up to rclcpp):