Call cmake add_custom_command after rosidl_generator_py is done?

Hi ROS!

So I recently stumbled across a bug with rosidl_generator_py that has a super easy fix, however I know it’ll be awhile before it gets implemented.

I’ve went ahead and tried to add the fix directly into a CMakelist.txt file for the problem-package, however I cant seem to get it to run after the rosidl files are generated. So instead I just warn the user to re-build the entire thing and then the cmake add_custom_command can find the generated file just fine and replace the bad bits with the good bits.

Question for the ROS community is does anyone know of a better way to do this? Either waiting until the rosidl_generator_py package is done doing its thing or re-running the CMake build from within the same CMake file :grinning_face_with_smiling_eyes:

Any advice or input is greatly appreciated. Interested to hear your thoughts!

You can accomplish this by specifying your target name followed by _python at the end, like this:

add_custom_command(
  TARGET ${PROJECT_NAME}__python
  POST_BUILD
  COMMAND echo "FOO"
  COMMENT ""
  VERBATIM)

see here for actual solution for the problem above: extra parenthesis in generated file · Issue #143 · ros2/rosidl_python · GitHub

2 Likes