From c5d69a40ae73d1de0f5f9ab1ea5f734fe0d4bba6 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Tue, 12 Sep 2023 15:29:43 -0700 Subject: [PATCH] gz-plugin CLI: set RPATH on macOS This CLI executable is installed to a subfolder of libexec, so it needs a different relative path to be used for the RPATH. Signed-off-by: Steve Peters --- loader/src/cmd/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/loader/src/cmd/CMakeLists.txt b/loader/src/cmd/CMakeLists.txt index 5dd10665..4caafb5a 100644 --- a/loader/src/cmd/CMakeLists.txt +++ b/loader/src/cmd/CMakeLists.txt @@ -14,6 +14,17 @@ target_link_libraries(${plugin_executable} set(EXE_INSTALL_DIR "${CMAKE_INSTALL_LIBEXECDIR}/gz/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}") +if (APPLE) + file(RELATIVE_PATH + EXE_INSTALL_DIR_RELATIVE_PATH_TO_PREFIX + "${CMAKE_INSTALL_PREFIX}/${EXE_INSTALL_DIR}" + "${CMAKE_INSTALL_PREFIX}" + ) + set_target_properties(${plugin_executable} PROPERTIES + INSTALL_RPATH "@loader_path/${EXE_INSTALL_DIR_RELATIVE_PATH_TO_PREFIX}/${CMAKE_INSTALL_LIBDIR}" + ) +endif() + install( TARGETS ${plugin_executable}