From 1a63bcf975e33710c2f4a6cdf3778ca824054bb1 Mon Sep 17 00:00:00 2001 From: Eduard Rius Date: Tue, 17 Feb 2026 16:02:16 +0000 Subject: [PATCH] Add conditional dependency to support 4.9 version --- behaviortree_ros2/CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/behaviortree_ros2/CMakeLists.txt b/behaviortree_ros2/CMakeLists.txt index 314edd0..a0dd732 100644 --- a/behaviortree_ros2/CMakeLists.txt +++ b/behaviortree_ros2/CMakeLists.txt @@ -38,11 +38,21 @@ target_link_libraries(${PROJECT_NAME} PUBLIC rclcpp::rclcpp rclcpp_action::rclcpp_action ament_index_cpp::ament_index_cpp - behaviortree_cpp::behaviortree_cpp ${btcpp_ros2_interfaces_TARGETS} bt_executor_parameters ) +if(TARGET BT::behaviortree_cpp) + target_link_libraries(${PROJECT_NAME} PUBLIC BT::behaviortree_cpp) +elseif(TARGET behaviortree_cpp::behaviortree_cpp) + target_link_libraries(${PROJECT_NAME} PUBLIC behaviortree_cpp::behaviortree_cpp) +else() + message(FATAL_ERROR + "behaviortree_cpp was found, but it did not export a known CMake target. " + "Expected BT::behaviortree_cpp or behaviortree_cpp::behaviortree_cpp." + ) +endif() + ###################################################### # INSTALL