0
$\begingroup$

Rosanswers logo

I have a pure python pacakge. Currently I have a CMakeLists and package.xml file set up so that it builds correctly with ros 1. If I add the ament_python build type to my package.xml then it also works great for ros 2 but then I can't build it for ros 1.

Is there any way out of this that doesn't require me to keep two branches/separate ros2 repo (that isn't writing a giant cmake file with lots of conditionals)?


Originally posted by Jari on ROS Answers with karma: 112 on 2019-10-15

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

As of format version 3 of the package manifest the build_type tag supports a condition attribute (see REP 149) which allows you to specify two different build types - e.g. one for ROS 1 and another for ROS 2.


Originally posted by Dirk Thomas with karma: 16276 on 2019-10-16

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by Jari on 2019-10-16:
Excellent. Can I use this now or is this coming in a future update?

Comment by Dirk Thomas on 2019-10-16:
That feature is already available for quite some time. So you can use it now.

Comment by Jari on 2019-10-17:
So apparently this works for catkin only if I put in two build_type tags and ensure that the cmake build type tag with condition $ROS_VERSION == 1 is listed first.

As far as I can tell catkin is ignoring that tag whereas colcon seems to be using it correctly. Does that sound right?

Edit: the condition that does work (and it's great that it does) is

  <export>
      <build_type condition="$ROS_VERSION == 1">cmake</build_type>
      <build_type condition="$ROS_VERSION == 2">ament_python</build_type>
  </export>

Comment by Dirk Thomas on 2019-10-17:
I would certainly call that a bug. Would you mind trying https://github.com/ros/catkin/pull/1038 and comment if that resolves the problem for you.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.