Skip to content

Commit fe019a9

Browse files
authored
Find zenoh_cpp_vendor package from ROS 2 (#614)
Signed-off-by: Ian Chen <ichen@openrobotics.org>
1 parent 1be9629 commit fe019a9

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

.github/ci/before_cmake.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Set ROS_DISTRO. This is needed for finding zenoh packages vendored by ROS 2
2+
export ROS_DISTRO="jazzy"

.github/ci/packages-noble.apt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
cppzmq-dev
2+
ros-jazzy-zenoh-cpp-vendor

CMakeLists.txt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,27 @@ gz_find_package(CPPZMQ REQUIRED PRIVATE
108108

109109
########################################
110110
# Find Zenoh
111-
find_package(zenohc)
112-
find_package(zenohcxx)
113-
if (NOT zenohcxx_DIR)
111+
112+
find_package(zenohc QUIET)
113+
find_package(zenohcxx QUIET)
114+
115+
# If both zenohc and zenohcpp packages are not found then
116+
# look for these pacakages installed by ROS 2 zenoh_cpp_vendor package
117+
if (NOT zenohc_FOUND AND NOT zenohcxx_FOUND)
118+
# Set CMAKE_PREFIX_PATH in order to find ROS 2 packages from plain cmake
119+
# package, see https://github.com/ament/ament_cmake/issues/304
120+
set(ros2_zenoh_cmake_path "/opt/ros/$ENV{ROS_DISTRO}/opt/zenoh_cpp_vendor/lib/cmake")
121+
if (EXISTS ${ros2_zenoh_cmake_path})
122+
list(PREPEND CMAKE_PREFIX_PATH ${ros2_zenoh_cmake_path})
123+
find_package(zenohc QUIET)
124+
find_package(zenohcxx QUIET)
125+
endif()
126+
endif ()
127+
128+
if (NOT zenohcxx_FOUND)
114129
message (STATUS "Looking for zenohcxx - not found")
115130
set (HAVE_ZENOH OFF CACHE BOOL "HAVE ZENOH" FORCE)
116-
elseif (NOT zenohc_DIR)
131+
elseif (NOT zenohc_FOUND)
117132
message (STATUS "Looking for zenohc - not found")
118133
set (HAVE_ZENOH OFF CACHE BOOL "HAVE ZENOH" FORCE)
119134
else ()

0 commit comments

Comments
 (0)