Skip to content

Commit 75c97d4

Browse files
committed
fix: detect Humble via rclcpp_VERSION instead of ROS_DISTRO env var
Commit 63e6e28 added a ROS_HUMBLE compile flag guarded by `if("$ENV{ROS_DISTRO}" STREQUAL "humble")`, but in the GitHub Actions build farm that check did not match even though ROS_DISTRO was "humble" at configure time. As a result the Humble build compiled the Jazzy+ branch and failed with: 'get_message_typesupport_handle' is not a member of 'rclcpp'; did you mean 'get_typesupport_handle'? Switch the detection to the rclcpp_VERSION variable populated by find_package(rclcpp). Humble ships rclcpp 16.x (threshold <17); Jazzy and newer ship 28.x+. This is deterministic and independent of the invoking shell's environment.
1 parent 63e6e28 commit 75c97d4

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ target_link_libraries( DataStreamROS2 commonROS)
4545
add_library( TopicPublisherROS2 SHARED TopicPublisherROS2/publisher_ros2.cpp)
4646
target_link_libraries( TopicPublisherROS2 commonROS)
4747

48-
message("AMENT_PREFIX_PATH = ${AMENT_PREFIX_PATH}")
49-
message("ROS_DISTRO (env) = $ENV{ROS_DISTRO}")
50-
51-
if("$ENV{ROS_DISTRO}" STREQUAL "humble")
52-
message(STATUS "Detected Humble")
48+
# rclcpp < 17 corresponds to Humble; newer distros expose the renamed
49+
# typesupport helpers and rosbag2 message fields used in the #else branches.
50+
if(rclcpp_VERSION VERSION_LESS "17")
51+
message(STATUS "Detected Humble (rclcpp ${rclcpp_VERSION})")
5352
target_compile_definitions(DataLoadROS2 PUBLIC ROS_HUMBLE)
5453
target_compile_definitions(TopicPublisherROS2 PUBLIC ROS_HUMBLE)
5554
target_compile_definitions(commonROS PUBLIC ROS_HUMBLE)

0 commit comments

Comments
 (0)