Skip to content

Commit 7edb11e

Browse files
authored
Update CMakeLists.txt
1 parent 59ae973 commit 7edb11e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,45 @@
11
cmake_minimum_required(VERSION 3.5)
22
project(zed_interfaces)
33

4+
################################################
5+
# Check the ROS2 version
6+
7+
set(ROS2_FOUND FALSE)
8+
if(DEFINED ENV{ROS_DISTRO})
9+
set(FOUND_ROS2_DISTRO $ENV{ROS_DISTRO})
10+
set(ROS2_FOUND TRUE)
11+
message("* Found ROS2 ${FOUND_ROS2_DISTRO}")
12+
else()
13+
message("* ROS2 distro variable not set. Trying to figure it out...")
14+
set(ROS2_DISTROS "ardent;crystal;dashing;eloquent;foxy;galactic;humble;rolling")
15+
set(ROS2_FOUND FALSE)
16+
foreach(distro ${ROS2_DISTROS})
17+
if(NOT ROS2_FOUND)
18+
find_path(RCLCPP_H rclcpp.hpp PATHS /opt/ros/${distro}/include/rclcpp)
19+
if(RCLCPP_H)
20+
message("* Found ROS2 ${distro}")
21+
set(FOUND_ROS2_DISTRO ${distro})
22+
set(ROS2_FOUND TRUE)
23+
endif()
24+
endif()
25+
endforeach()
26+
endif(DEFINED ENV{ROS_DISTRO})
27+
28+
if(ROS2_FOUND)
29+
if(${FOUND_ROS2_DISTRO} STREQUAL "foxy")
30+
message("* ROS2 ${FOUND_ROS2_DISTRO} is officially supported by this package.")
31+
add_definitions(-DFOUND_FOXY)
32+
elseif(${FOUND_ROS2_DISTRO} STREQUAL "humble")
33+
message("* ROS2 ${FOUND_ROS2_DISTRO} is officially supported by this package.")
34+
add_definitions(-DFOUND_HUMBLE)
35+
else()
36+
message("*** WARNING *** ROS2 ${FOUND_ROS2_DISTRO} is not officially supported by this package. Correct working is not guarantee.")
37+
endif()
38+
else()
39+
message("*** WARNING *** ROS2 distro is unknown. This package could not work correctly.")
40+
endif()
41+
################################################
42+
443
# Default to C++14
544
if(NOT CMAKE_CXX_STANDARD)
645
set(CMAKE_CXX_STANDARD 14)

0 commit comments

Comments
 (0)