diff --git a/src/perception/rai_whatisee/CMakeLists.txt b/src/perception/rai_whatisee/CMakeLists.txt index 1cb779d27..216338cd3 100644 --- a/src/perception/rai_whatisee/CMakeLists.txt +++ b/src/perception/rai_whatisee/CMakeLists.txt @@ -5,6 +5,19 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() +# Determine ROS 2 distribution +if(DEFINED ENV{ROS_DISTRO}) + if($ENV{ROS_DISTRO} STREQUAL "humble") + add_definitions(-DROS_DISTRO_HUMBLE) + elseif($ENV{ROS_DISTRO} STREQUAL "jazzy") + add_definitions(-DROS_DISTRO_JAZZY) + else() + message(WARNING "Unsupported ROS 2 distribution: $ENV{ROS_DISTRO}. Defaulting to .hpp include.") + endif() +else() + message(FATAL_ERROR "ROS_DISTRO environment variable not set. Make sure to source your ROS 2 distribution before compiling.") +endif() + # find dependencies find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) diff --git a/src/perception/rai_whatisee/src/rai_whatisee_node.cpp b/src/perception/rai_whatisee/src/rai_whatisee_node.cpp index b7146b62d..c911dc322 100644 --- a/src/perception/rai_whatisee/src/rai_whatisee_node.cpp +++ b/src/perception/rai_whatisee/src/rai_whatisee_node.cpp @@ -12,7 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if defined(ROS_DISTRO_HUMBLE) #include +#elif defined(ROS_DISTRO_JAZZY) +#include +#else +#include // Default to .hpp for future distributions +#endif #include #include