From 548133478496abf3f56b811d3dc35833567b3aeb Mon Sep 17 00:00:00 2001 From: artcore-c Date: Sun, 6 Jul 2025 23:16:52 -0400 Subject: [PATCH] Fix macOS RPATH handling and install rules for Iceoryx platform modules --- iceoryx_binding_c/CMakeLists.txt | 9 ++++++ iceoryx_hoofs/CMakeLists.txt | 29 +++++++++++++++++++ .../cmake/iceoryx_platformConfig.cmake.in | 13 +++++++++ iceoryx_hoofs/platform/CMakeLists.txt | 25 ++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 iceoryx_hoofs/cmake/iceoryx_platformConfig.cmake.in diff --git a/iceoryx_binding_c/CMakeLists.txt b/iceoryx_binding_c/CMakeLists.txt index 7863ddb265..7be8042b61 100644 --- a/iceoryx_binding_c/CMakeLists.txt +++ b/iceoryx_binding_c/CMakeLists.txt @@ -114,6 +114,15 @@ endif() target_compile_options(${PROJECT_NAME} PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) +# Ensure dependent dylibs can be found via @rpath on macOS +if(APPLE) + set_target_properties(iceoryx_binding_c PROPERTIES + INSTALL_RPATH "@loader_path/../lib" + BUILD_WITH_INSTALL_RPATH TRUE + MACOSX_RPATH ON + ) +endif() + # ########## build test executables ########## # diff --git a/iceoryx_hoofs/CMakeLists.txt b/iceoryx_hoofs/CMakeLists.txt index f7cb43bd9f..e4e63ce241 100644 --- a/iceoryx_hoofs/CMakeLists.txt +++ b/iceoryx_hoofs/CMakeLists.txt @@ -241,6 +241,35 @@ install( DESTINATION ${DESTINATION_CONFIGDIR} ) +# Add after existing install() commands +install(EXPORT iceoryx_platformTargets + FILE iceoryx_platformTargets.cmake + NAMESPACE iceoryx:: + DESTINATION lib/cmake/iceoryx_platform +) + +include(CMakePackageConfigHelpers) +# Add this before configure_package_config_file +get_filename_component(ICEORYX_PLATFORM_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/platform/include" ABSOLUTE) +configure_package_config_file( + cmake/iceoryx_platformConfig.cmake.in + iceoryx_platformConfig.cmake + INSTALL_DESTINATION lib/cmake/iceoryx_platform + PATH_VARS ICEORYX_PLATFORM_INCLUDE_DIRS +) + +write_basic_package_version_file( + iceoryx_platformConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/iceoryx_platformConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/iceoryx_platformConfigVersion.cmake" + DESTINATION lib/cmake/iceoryx_platform +) + if(BUILD_TEST) add_subdirectory(test) endif(BUILD_TEST) diff --git a/iceoryx_hoofs/cmake/iceoryx_platformConfig.cmake.in b/iceoryx_hoofs/cmake/iceoryx_platformConfig.cmake.in new file mode 100644 index 0000000000..12001fa831 --- /dev/null +++ b/iceoryx_hoofs/cmake/iceoryx_platformConfig.cmake.in @@ -0,0 +1,13 @@ +# iceoryx_platformConfig.cmake.in + +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(iceoryx_hoofs) + +include("${CMAKE_CURRENT_LIST_DIR}/iceoryx_platformTargets.cmake") + +# Add platform-specific include paths +get_filename_component(ICEORYX_PLATFORM_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/../../include/iceoryx_hoofs/platform" ABSOLUTE) +set(ICEORYX_PLATFORM_INCLUDE_DIRS ${ICEORYX_PLATFORM_INCLUDE_DIRS} CACHE PATH "Iceoryx platform include directories") +set_and_check(ICEORYX_PLATFORM_INCLUDE_DIRS "@PACKAGE_ICEORYX_PLATFORM_INCLUDE_DIRS@") \ No newline at end of file diff --git a/iceoryx_hoofs/platform/CMakeLists.txt b/iceoryx_hoofs/platform/CMakeLists.txt index 78bad09f88..2a0a1e2692 100644 --- a/iceoryx_hoofs/platform/CMakeLists.txt +++ b/iceoryx_hoofs/platform/CMakeLists.txt @@ -52,6 +52,31 @@ set_target_properties(iceoryx_platform PROPERTIES target_link_libraries(iceoryx_platform PRIVATE ${ICEORYX_SANITIZER_FLAGS}) +# Add right after target_link_libraries(iceoryx_platform PRIVATE ${ICEORYX_SANITIZER_FLAGS}) + +# Add installation rules for all platforms +install(TARGETS iceoryx_platform + EXPORT iceoryx_platformTargets + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +) + +# Add platform-specific installation for headers +install(DIRECTORY ${ICEORYX_PLATFORM}/include/ + DESTINATION include/iceoryx_hoofs/platform +) + +# macOS-specific RPATH handling +if(APPLE) + set_target_properties(iceoryx_platform PROPERTIES + INSTALL_RPATH "@loader_path/../lib;@loader_path/../../iceoryx_hoofs/lib" + MACOSX_RPATH ON + BUILD_WITH_INSTALL_RPATH TRUE + ) +endif() + target_compile_options(iceoryx_platform PRIVATE ${ICEORYX_WARNINGS} ${ICEORYX_SANITIZER_FLAGS}) if(LINUX)