[ros-users] [Discourse.ros.org] [Next Generation ROS] ROS2: How to use custom message in project where it's declared?

Mikael Arguedas ros.discourse at gmail.com
Wed Jun 28 00:04:05 UTC 2017



It's true that most our message package are pure message packages and thus do not try to include/link against themselves. The trick here is that you need to use the macro [rosidl_target_interfaces](https://github.com/ros2/rosidl/blob/ef23dbf8e07af2381757829cacf9be97173acba6/rosidl_cmake/cmake/rosidl_target_interfaces.cmake)
```
rosidl_target_interfaces(MY_TARGET_NAME
      ${PROJECT_NAME} "rosidl_typesupport_cpp")
```

You can look at the [composition demo](https://github.com/ros2/demos/blob/67053598cac9fbc5f3da421b6b300d6ca0161b8e/composition/CMakeLists.txt#L119-L120) CMake code for an example.

I agree that this is not well documented and that an addition to https://github.com/ros2/ros2/wiki/Defining-custom-interfaces-(msg-srv) would be valuable





---
[Visit Topic](https://discourse.ros.org/t/ros2-how-to-use-custom-message-in-project-where-its-declared/2071/2) or reply to this email to respond.




More information about the ros-users mailing list