fix(zenoh): px4_sitl_zenoh build on macOS (#29538)

zenoh is now part of px4_sitl_default, so the macOS SITL build compiles
it and fails in two places:

- msg: zenoh_topics was a static library with only a header as its
  source. macOS ar rejects the resulting empty archive ("no archive
  members specified"). It only orders header generation, so make it a
  custom target.
- zenoh: POSIX_COMPATIBLE makes zenoh-pico define ZENOH_LINUX ahead of
  its own Darwin detection, which pulls in the Linux-only getrandom().
  Set it only on non-Apple platforms. Linux is unaffected, and NuttX
  (CMAKE_SYSTEM_NAME Generic) keeps it.

Also mark the uORB_Zenoh_Subscriber overrides, consistent with the
publisher.

Signed-off-by: Beniamino Pozzan <beniamino.pozzan@gmail.com>
Co-authored-by: Farhang <46557204+farhangnaderi@users.noreply.github.com>
Co-authored-by: Beniamino Pozzan <beniamino.pozzan@gmail.com>
This commit is contained in:
authored and GitHub committed 2026-11-08 22:15:08 -05:00
1 parent 100d257c91
commit f9088053ab
3 files changed
+9 -6

No files matched your search

+4 -3
View File
@@ -624,7 +624,8 @@ if(CONFIG_MODULES_ZENOH)
COMMENT "Generating Zenoh Topic Code"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
)
add_library(zenoh_topics ${PX4_BINARY_DIR}/src/modules/zenoh/uorb_pubsub_factory.hpp)
set_target_properties(zenoh_topics PROPERTIES LINKER_LANGUAGE CXX)
)
add_custom_target(zenoh_topics
DEPENDS ${PX4_BINARY_DIR}/src/modules/zenoh/uorb_pubsub_factory.hpp
)
endif()
+3 -1
View File
@@ -37,7 +37,9 @@ function(message)
endif()
endfunction()
set(POSIX_COMPATIBLE YES)
if(NOT APPLE)
set(POSIX_COMPATIBLE YES)
endif()
set(BUILD_SHARED_LIBS OFF)
set(BUILD_TESTING OFF)
set(CHECK_THREADS NO)
@@ -73,7 +73,7 @@ public:
}
// Update the uORB Subscription and broadcast a Zenoh ROS2 message
void data_handler(const z_loaned_sample_t *sample)
void data_handler(const z_loaned_sample_t *sample) override
{
char data[_uorb_meta->o_size + CDR_SAFETY_MARGIN];
@@ -133,7 +133,7 @@ public:
memcpy(data, &now, sizeof(hrt_abstime));
}
void print()
void print() override
{
Zenoh_Subscriber::print("uORB", _uorb_meta->o_name);
}