For Context this is the first time I have had to use CMake so I'm not very familiar with how it works. I am trying to follow the ros_gz_bridge github examples but I don't understand how to link to the target. I have 2 ros2 packages, one that defines gazebo msg types called eufs_msg, and another that uses them (ros_gz_bridge) (There will be more that use them later). I need to be able to use the generated messages in the ros_gz_bridge package.
I need the built protobuf (.pb and .pb.hh) to be linked into the ros_gz_brdige package byinclude <gz/driverless_msgs/"msg">
but I am not sure how I am supposed to link to the generated C files.
The bit I am confused about is the target custom_msgs_gen
's comments say cmake target to be generated. How do I generate it. There are no C files in the package, it only includes the protobuf definitions. Or is the target already generated.
Also how would I like to this in the other package. This may be an obvious question but I can't quite wrap my head around how this stuff works.
# Example of custom messages that depend on gz.msgs
set(MSGS_PROTOS ${CMAKE_CURRENT_SOURCE_DIR}/proto/gz/custom_msgs/vector3d.proto)
gz_msgs_generate_messages(
# The cmake target to be generated for libraries/executables to link
TARGET custom_msgs_gen
# The protobuf package to generate (Typically based on the path)
PROTO_PACKAGE "gz.custom_msgs"
# The path to the base directory of the proto files
# All import paths should be relative to this (eg gz/custom_msgs/vector3d.proto)
MSGS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/proto
# List of proto files to generate
MSGS_PROTOS ${MSGS_PROTOS}
# List of message targets this library imports from
DEPENDENCIES gz_msgs_gen)
This is the example I am working from
Currently this is what mine looks like
gz_msgs_generate_messages(
TARGET eufs_msg_gen
PROTO_PACKAGE "gz.driverless_msgs"
MSGS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/proto
MSGS_PROTOS ${MSGS_PROTOS}
DEPENDENCIES gz-msgs10::gz-msgs10
)
When I use this to generate the build protobuf files they are built under ws/build/eufs_msg/msg/eufs_msg-eufs_msg_gen_genmsg/gz.
They are being built properly as I can view them when I run the gz msg -l
command.
Let me know if any more details are required, thanks.