Skip to content

Commit

Permalink
Dependency: Add detail about defining deps in package.xml, CMakeLists…
Browse files Browse the repository at this point in the history
….txt
  • Loading branch information
130s committed Jun 29, 2023
1 parent af4933e commit 32447af
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions source/Tutorials/Intermediate/Dependency/Rosdep.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ They specify in what situation each of the dependencies are required in.

These dependencies are manually populated in the ``package.xml`` file by the package's creators and should be an exhaustive list of any non-builtin libraries and packages it requires.

You can find more in detail about the `types of dependencies and how to define them in package.xml and CMakeLists.txt Catkin's document <./define_dependencies.rst>`_.

How does rosdep work?
---------------------

Expand Down
61 changes: 61 additions & 0 deletions source/Tutorials/Intermediate/Dependency/define_dependencies.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Defining dependencies in your ament package
===========================================

**Goal:** Understand the types of dependencies supported by ``ament`` package.

**Tutorial level:** Intermediate

**Time:** 5 minutes

.. contents:: Contents
:depth: 2
:local:

ament package dependencies
--------------------------

When your package depends on C++ packages, source or binary, there are usually several kinds of dependencies which must be declared in your ``package.xml`` and ``CMakeLists.txt`` files. This document describes about package.xml. For CMakeLists.txt, see `ament_cmake documentation <../../../How-To-Guides/Ament-CMake-Documentation.rst>`_.

package.xml
-----------

Your package dependencies must be declared in ``package.xml``. If they are missing or incorrect, you may still be able to build from source and run tests in your own workspace, but ``ament/ROS`` toolsuite, e.g. ``colcon``, `rosdep <Rosdep.rst>`_, may not function. Also `release into public registry <../../../How-To-Guides/Releasing/>`_ would not be an option. Others rely on this information to install the software they need for using your package.

``<depend>``
''''''''''''

It is generally sufficient to mention each ROS package dependency once, like this::

<depend>rclcpp</depend>

Sometimes, you may need or want more granularity for certain dependencies. The following sections explain how to do that. If in doubt, use the ``<depend>`` tag, it's simpler.

``<build_depend>``
''''''''''''''''''

If you only use some particular dependency for building your package, and not at execution time, you can use the ``<build_depend>`` tag.
For example, the ROS ``angles`` package only provides C++ headers and CMake configuration files::

<build_depend>angles</build_depend>

With this type of dependency, an installed binary of your package does not require the angles package to be installed.

**But**, that could create a problem if your package exports a header that includes the ``<angles/angles.h>`` header. In that case you also need a ``<build_export_depend>``.

``<build_export_depend>``
'''''''''''''''''''''''''

If you export a header that includes ``<angles/angles.h>``, it will be needed by other packages that ``<build_depend>`` on yours::

<build_export_depend>angles</build_export_depend>

This mainly applies to headers and CMake configuration files. Library packages referenced by libraries you export should normally specify ``<depend>``, because they are also needed at execution time.

``<exec_depend>``
'''''''''''''''''

This tag declares dependencies for shared libraries, executables, Python modules, launch scripts and other files required when running your package. For example, the ROS ``launch_xml`` package provides
launch scripts, which are only needed at execution time::

<exec_depend>launch_xml</exec_depend>

0 comments on commit 32447af

Please sign in to comment.