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.