ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Since targets are now built with plain CMake macros (add_executable
, add_library
, etc), there's no longer a list of targets built by a given package, and thus, a dependency cannot be made on messages first. What you need to do, for a given project is explicitly add a dependency on the CMake target representing the message generation step for that language. If the project name is "foo_pkg" and is written in c++ then this target names is "foo_pkg_gencpp" in CMakeLists.txt this looks like:
project_name(foo_pkg)
# ...
# For a library
add_library(foo src/foo_lib.cpp)
add_dependencies(foo ${PROJECT_NAME}_gencpp)
# For an executable
add_executable(foo_node srd/foo_node.cpp)
add_dependencies(foo_node ${PROJECT_NAME}_gencpp)
This is actually documented here (maybe it could be put in a more obvious place): http://ros.org/wiki/catkin/CMakeLists.txt#Important_Prerequisites.2BAC8-Constraints
See an example here: https://github.com/jhu-lcsr-forks/ros_control/blob/bb356c02223dadcdafce635a43d2a8e4d12df23d/control_toolbox/CMakeLists.txt
2 | No.2 Revision |
Since targets are now built with plain CMake macros (add_executable
, add_library
, etc), there's no longer a list of targets built by a given package, and thus, a dependency cannot be made on messages first. What you need to do, for a given project is explicitly add a dependency on the CMake target representing the message generation step for that language. If the project name is "foo_pkg" and is written in c++ then this target names is "foo_pkg_gencpp" in CMakeLists.txt this looks like:
project_name(foo_pkg)
# ...
# For a library
add_library(foo src/foo_lib.cpp)
add_dependencies(foo ${PROJECT_NAME}_gencpp)
# For an executable
add_executable(foo_node srd/foo_node.cpp)
add_dependencies(foo_node ${PROJECT_NAME}_gencpp)
This is actually documented here (maybe it could be put in a more obvious place): http://ros.org/wiki/catkin/CMakeLists.txt#Important_Prerequisites.2BAC8-Constraints
See an example here:
https://github.com/jhu-lcsr-forks/ros_control/blob/bb356c02223dadcdafce635a43d2a8e4d12df23d/control_toolbox/CMakeLists.txt