From 9ab5b5a176105576a1ec788f257430373135afcc Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 14 Nov 2024 22:26:31 +1300 Subject: [PATCH] cmake: set RPATH of installed mavsdk_server This allows to install the mavsdk_server binary in any install prefix and run it. --- src/mavsdk_server/src/CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/mavsdk_server/src/CMakeLists.txt b/src/mavsdk_server/src/CMakeLists.txt index 30fd9db34..bc3ec9454 100644 --- a/src/mavsdk_server/src/CMakeLists.txt +++ b/src/mavsdk_server/src/CMakeLists.txt @@ -7,6 +7,8 @@ list(APPEND MAVSDK_SERVER_SOURCES grpc_server.cpp ) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + set(COMPONENTS_LIST ${ENABLED_PLUGINS}) list(APPEND COMPONENTS_LIST core) foreach(COMPONENT_NAME ${COMPONENTS_LIST}) @@ -109,8 +111,20 @@ if(NOT IOS AND NOT ANDROID) EXPORT mavsdk-targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) + + if (BUILD_SHARED_LIBS) + set_target_properties(mavsdk_server_bin PROPERTIES + INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}" + ) + + set_target_properties(mavsdk_server + PROPERTIES + INSTALL_RPATH "$ORIGIN" + ) + endif() endif() + # iOS builds mavsdk_server.framework if(IOS OR (APPLE AND MACOS_FRAMEWORK)) set_target_properties(mavsdk_server PROPERTIES