Previous topic

genmsg: generating code from ros .msg format

Next topic

genmsg Python API

This Page

User macro reference

add_message_files(DIRECTORY dir FILES file1 [file2...] [PACKAGE pkgname] [NOINSTALL])
Parameters:
  • DIRECTORY – Directory containing messages. May be absolute or relative to CMAKE_CURRENT_SOURCE_DIR.
  • FILES – Files containing messages, relative to msgdir
  • PACKAGE – Optional alternate packagename (if the current project doesn’t match the desired namespace for the messages)
  • NOINSTALL – Do not automatically install the messages to the package’s share/ directory.

Register the listed files as requiring message generation and installation.

add_service_files(DIRECTORY dir FILES file1 [file2...] [PACKAGE pkgname] [NOINSTALL])

Same as add_message_files... but for services.

generate_messages(DEPENDENCIES deps [LANGS lang1 lang2...])
Parameters:
  • DEPENDENCIES – Names of packages containing messages contained by messages in the current package. Got it? i.e. if one of our messages contains std_msgs.Header, std_msgs should appear in this list.
  • LANGS – Restrict generation to the listed languages.

Triggers the generation of message generation targets. i.e. in project foo with generators gencpp and genpy accessible in the workspace, triggers creation of targets foo_gencpp and foo_genpy.

Now, if your code does depend on generated messages you need to add a dependency. E.g. if you target foo depends on the C++ messages of your current bar project, you need to add:

add_dependencies(foo bar_gencpp)

(the bar_cpp target is automatically created when you generate messages)