diff --git a/rmw_zenoh_cpp/CMakeLists.txt b/rmw_zenoh_cpp/CMakeLists.txt index 9565a304..7c8ccd0c 100644 --- a/rmw_zenoh_cpp/CMakeLists.txt +++ b/rmw_zenoh_cpp/CMakeLists.txt @@ -13,7 +13,7 @@ endif() # find dependencies find_package(ament_cmake REQUIRED) - +find_package(zenohc REQUIRED) find_package(ament_index_cpp REQUIRED) find_package(fastcdr CONFIG REQUIRED) find_package(rcpputils REQUIRED) @@ -23,9 +23,6 @@ find_package(rosidl_typesupport_fastrtps_cpp REQUIRED) find_package(rmw REQUIRED) find_package(zenoh_c_vendor REQUIRED) find_package(zenohc_debug QUIET) -if(NOT zenohc_debug_FOUND) - find_package(zenohc REQUIRED) -endif() add_library(rmw_zenoh_cpp SHARED src/detail/attachment_helpers.cpp diff --git a/zenoh_c_vendor/CMakeLists.txt b/zenoh_c_vendor/CMakeLists.txt index 943ebb1d..fcfdfb09 100644 --- a/zenoh_c_vendor/CMakeLists.txt +++ b/zenoh_c_vendor/CMakeLists.txt @@ -8,26 +8,28 @@ if(NOT CMAKE_CXX_STANDARD) endif() find_package(ament_cmake REQUIRED) -find_package(ament_cmake_vendor_package REQUIRED) - -# Disable default features and enable only the most useful ones. This reduces build time and footprint. -# For a complete list of features see: https://github.com/eclipse-zenoh/zenoh/blob/main/zenoh/Cargo.toml -# Note: We separate the two args needed for cargo with "$" and not ";" as the -# latter is a list separater in cmake and hence the string will be split into two -# when expanded. -set(ZENOHC_CARGO_FLAGS "--no-default-features$--features=shared-memory zenoh/transport_compression zenoh/transport_tcp zenoh/transport_tls") - -# Set VCS_VERSION to include latest changes from zenoh-c to benefit from : -# - https://github.com/eclipse-zenoh/zenoh-c/pull/340 (fix build issue) -# - https://github.com/eclipse-zenoh/zenoh/pull/1021 (fix timeout issue with queries) -# - https://github.com/eclipse-zenoh/zenoh/pull/1022 (fix empty messages received if payload >btach size) -# - https://github.com/eclipse-zenoh/zenoh-c/pull/358 (fix debian packaging issue: https://github.com/jspricke/ros-deb-builder-action/issues/49) -# - https://github.com/eclipse-zenoh/zenoh/pull/1150 (fix deadlock issue https://github.com/ros2/rmw_zenoh/issues/182) -ament_vendor(zenoh_c_vendor - VCS_URL https://github.com/eclipse-zenoh/zenoh-c - VCS_VERSION dev/1.0.0 - CMAKE_ARGS - "-DZENOHC_CARGO_FLAGS=${ZENOHC_CARGO_FLAGS}" + +# Include the ExternalProject module +include(ExternalProject) + +# Define installation directory +set(ZENOHC_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}) + +# Add the external project +ExternalProject_Add(zenohc + PREFIX ${CMAKE_BINARY_DIR}/zenohc + GIT_REPOSITORY https://github.com/eclipse-zenoh/zenoh-c.git + GIT_TAG dev/1.0.0 + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${ZENOHC_INSTALL_DIR} + BUILD_IN_SOURCE 1 ) +# Create a custom target to manage dependencies +add_custom_target(zenoh_c_vendor ALL + DEPENDS zenohc +) + +# Add the installation directory to CMAKE_PREFIX_PATH +list(APPEND CMAKE_PREFIX_PATH ${ZENOHC_INSTALL_DIR}) + ament_package()