From d73e277da9467e4e2bd1a9de5e853bc04957e9bc Mon Sep 17 00:00:00 2001
From: Guilhem Saurel <guilhem.saurel@laas.fr>
Date: Wed, 2 Dec 2020 15:37:57 +0100
Subject: [PATCH] [CMake] set RPATH for plugins

to fix debian packages creation on ROS buildfarm:

00:12:11 dpkg-shlibdeps: error: cannot find library libtracer.so.4.3.1 needed by
debian/ros-noetic-dynamic-graph/opt/ros/noetic/lib/dynamic-graph-plugins/libtracer-real-time.so.4.3.1
(ELF format: 'elf64-x86-64' abi: '0201003e00000000'; RPATH: '')
---
 src/CMakeLists.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 79d64b2..4cd68f4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,3 +1,5 @@
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+
 SET(plugins
   traces/tracer
   traces/tracer-real-time
@@ -12,6 +14,7 @@ FOREACH(plugin ${plugins})
   IF(SUFFIX_SO_VERSION)
     SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
   ENDIF(SUFFIX_SO_VERSION)
+  SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES INSTALL_RPATH $ORIGIN)
 
   TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${PROJECT_NAME} ${${LIBRARY_NAME}_deps})
 
-- 
GitLab