Synchronizes ROS 2 dependencies between CMakeLists.txt and package.xml. Use when adding, removing, or modifying package dependencies in a ROS 2 C++ or Python package to ensure build/run/test configurations match exactly.
This skill ensures that ROS 2 packages have perfectly synchronized dependencies across their build configurations (CMakeLists.txt for C++ packages, or setup.py for Python) and package manifests (package.xml).
package.xml.package.xml based on how the dependency is used.When tasked with syncing or checking dependencies for a specific package, follow these steps:
Check the package root for CMakeLists.txt (C++ or mixed) or (Pure Python).
setup.pyRead the build configuration to find all required dependencies.
For C++ (CMakeLists.txt):
find_package(<pkg_name> REQUIRED) calls.ament_target_dependencies(<target> <pkg_name1> <pkg_name2>) calls.For Python (setup.py / setup.cfg):
install_requires array.Read package.xml and categorize the existing dependencies by their XML tags.
<build_depend>: Required to build the package (e.g., C++ headers).<exec_depend>: Required to run the package (e.g., Python packages, shared libraries, launch files).<depend>: A shorthand tag that implies BOTH <build_depend> and <exec_depend>. Prefer this for C++ libraries that you link against and run with.<buildtool_depend>: Tools required to build (usually just ament_cmake or ament_python).<test_depend>: Required only for running tests (e.g., ament_lint_auto, gtest).Compare the lists from Step 2 and Step 3.
CMakeLists.txt package names often differ from package.xml rosdep keys (e.g., find_package(Eigen3) maps to <depend>eigen</depend>, Boost maps to boost). Do not blindly copy-paste CMake names into XML.package.xml: If find_package(X) exists, but X (or its rosdep equivalent) is not in package.xml, add it. For C++, usually add as <depend>X</depend>. For Python, add as <exec_depend>X</exec_depend>.CMakeLists.txt: If <depend>Y</depend> exists in package.xml, but there is no find_package(Y) AND it's a C++ package, investigate. If Y is truly unused in the source code, remove it from package.xml.ament_lint_auto are strictly under <test_depend>, not <depend>.Write the corrected CMakeLists.txt and package.xml files. Ensure XML formatting and indentation match the surrounding file.