ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can I link properly these executables? Is it ok to call find_package(catkin REQUIRED COMPONENTS ...) several times?

No, that won't work (due to caching, CMake may not actually even call find_package() again).

A work-around could be to not use find_package(catkin .. COMPONENTS ..), but to find_package(..) each of your dependencies separately (so find_package(sensor_msgs REQUIRED) and find_package(std_msgs REQUIRED)) and then manually add the results of those calls to the include and linker paths of the respective binaries.


But an observation: if the executables are really so different that they don't have (m)any shared dependencies, I would ask myself whether these executables should be hosted by the same package.

Perhaps they should be in a package of their own.

How can I link properly these executables? Is it ok to call find_package(catkin REQUIRED COMPONENTS ...) several times?

No, that won't work (due to caching, CMake may not actually even call find_package() again).

A work-around could be to not use find_package(catkin .. COMPONENTS ..), but to find_package(..) each of your dependencies separately (so find_package(sensor_msgs REQUIRED) and find_package(std_msgs REQUIRED)) and then manually add the results of those calls to the include and linker link paths of the respective binaries.

how about the include_directories statements?

CMake supports per target properties, such as include and link paths (with either set_target_properties(..) or target_include_directories(..)). You could use those.


But an observation: if the executables are really so different that they don't have (m)any shared dependencies, I would ask myself whether these executables should be hosted by the same package.

Perhaps they should be in a package of their own.