Skip to content

Should I use ament_export_dependencies for PRIVATE dependency? #532

@felixf4xu

Description

@felixf4xu

Hi,

I see several examples in ROS2 code that ament_export_dependencies is used for PRIVATE dependencies, like

  1. kdl_parser project
    https://github.com/ros/kdl_parser/blob/jazzy/kdl_parser/CMakeLists.txt#L28
target_link_libraries(${PROJECT_NAME} PRIVATE
  rcutils::rcutils
  urdf::urdf)

and it's exported:
https://github.com/ros/kdl_parser/blob/jazzy/kdl_parser/CMakeLists.txt#L59

ament_export_dependencies(rcutils)
  1. camera_calibration_parsers project

https://github.com/ros-perception/image_common/blob/jazzy/camera_calibration_parsers/CMakeLists.txt#L33

target_link_libraries(${PROJECT_NAME} PRIVATE
  rclcpp::rclcpp
  yaml-cpp::yaml-cpp)

and it's exported:
https://github.com/ros-perception/image_common/blob/jazzy/camera_calibration_parsers/CMakeLists.txt#L88

ament_export_dependencies(rclcpp sensor_msgs yaml_cpp_vendor)

I can list more if I search more in the ros2 source code. I have to say, those usage really confused me. For PRIVATE dependencies, I don't think it's necessary to export them.

Before I raise an issue for those projects, I'd like to make sure the usage of ament_export_dependencies for PRIVATE dependencies, it's not mentioned here https://docs.ros.org/en/jazzy/How-To-Guides/Ament-CMake-Documentation.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions