From f2c5b35724fada6485eae5e96ab7dc91b52dc192 Mon Sep 17 00:00:00 2001 From: Mateusz Szczygielski <112629916+msz-rai@users.noreply.github.com> Date: Mon, 3 Apr 2023 18:07:29 +0200 Subject: [PATCH] Fix RobotecGPULidar library linking (#11) * Create install step for cmake * Update README * Downgrade cmake version to Ubuntu20 default (3.16) * Simplify rpath setting mechanism --- .gitignore | 1 + CMakeLists.txt | 6 ++++-- README.md | 18 +++++++++++------- RGLServerPlugin/CMakeLists.txt | 13 ++++++++++++- RGLVisualize/CMakeLists.txt | 10 ++++++++-- 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 13f6ba6..1fe9f83 100644 --- a/.gitignore +++ b/.gitignore @@ -33,5 +33,6 @@ .idea build +install cmake-build-debug RGLServerPlugin/include/rgl diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bf5c8d..332a1c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.16) project(RGLGazeboPlugin) +set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/install") + add_subdirectory(RGLServerPlugin) -add_subdirectory(RGLVisualize) \ No newline at end of file +add_subdirectory(RGLVisualize) diff --git a/README.md b/README.md index 57658b0..6fc2870 100644 --- a/README.md +++ b/README.md @@ -35,17 +35,19 @@ Key features: - Move libraries to the plugin's directories. ```shell # If Gazebo installed from apt: + cp libRobotecGPULidar.so /usr/lib/x86_64-linux-gnu/ign-gazebo-6/plugins/ cp libRGLServerPluginInstance.so /usr/lib/x86_64-linux-gnu/ign-gazebo-6/plugins/ cp libRGLServerPluginManager.so /usr/lib/x86_64-linux-gnu/ign-gazebo-6/plugins/ cp libRGLVisualize.so /usr/lib/x86_64-linux-gnu/ign-gazebo-6/plugins/gui/ ``` - Or set environment variables: ```shell - # Assuming that libRGLServerPluginInstance.so and libRGLServerPluginManager.so - # are located in RGLServerPlugins directory, - # and libRGLVisualize.so in RGLGuiPlugins. - export IGN_GAZEBO_SYSTEM_PLUGIN_PATH=`pwd`/RGLServerPlugins:$IGN_GAZEBO_SYSTEM_PLUGIN_PATH - export IGN_GUI_PLUGIN_PATH=`pwd`/RGLGuiPlugins:$IGN_GUI_PLUGIN_PATH + # Assuming that libraries: + # libRGLServerPluginInstance.so, libRGLServerPluginManager.so and libRobotecGPULidar.so + # are located in RGLServerPlugin directory, + # and libRGLVisualize.so in RGLGuiPlugin. + export IGN_GAZEBO_SYSTEM_PLUGIN_PATH=`pwd`/RGLServerPlugin:$IGN_GAZEBO_SYSTEM_PLUGIN_PATH + export IGN_GUI_PLUGIN_PATH=`pwd`/RGLGuiPlugin:$IGN_GUI_PLUGIN_PATH ``` ### Building from source ```shell @@ -53,8 +55,10 @@ mkdir build cd build cmake .. make -j -export IGN_GAZEBO_SYSTEM_PLUGIN_PATH=`pwd`/RGLServerPlugin:$IGN_GAZEBO_SYSTEM_PLUGIN_PATH -export IGN_GUI_PLUGIN_PATH=`pwd`/RGLVisualize:$IGN_GUI_PLUGIN_PATH +make install +cd .. +export IGN_GAZEBO_SYSTEM_PLUGIN_PATH=`pwd`/install/RGLServerPlugin:$IGN_GAZEBO_SYSTEM_PLUGIN_PATH +export IGN_GUI_PLUGIN_PATH=`pwd`/install/RGLVisualize:$IGN_GUI_PLUGIN_PATH ``` ## Demo: diff --git a/RGLServerPlugin/CMakeLists.txt b/RGLServerPlugin/CMakeLists.txt index 73beb1c..eef7db9 100644 --- a/RGLServerPlugin/CMakeLists.txt +++ b/RGLServerPlugin/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.16) project(RGLServerPlugin) set(CMAKE_CXX_STANDARD 20) @@ -33,6 +33,7 @@ target_link_libraries(RGLServerPluginManager ignition-plugin1::ignition-plugin1 ${RobotecGPULidar} ) +set_target_properties(RGLServerPluginManager PROPERTIES INSTALL_RPATH "$ORIGIN") add_library(RGLServerPluginInstance SHARED src/RGLServerPluginInstance.cc src/Lidar.cc src/Utils.cc src/LidarPatternLoader.cc) target_link_libraries(RGLServerPluginInstance @@ -40,3 +41,13 @@ target_link_libraries(RGLServerPluginInstance ignition-plugin1::ignition-plugin1 ${RobotecGPULidar} ) +set_target_properties(RGLServerPluginInstance PROPERTIES INSTALL_RPATH "$ORIGIN") + +## Install libraries + +install(TARGETS RGLServerPluginInstance RGLServerPluginManager + DESTINATION RGLServerPlugin +) +install(FILES ${RobotecGPULidar} + DESTINATION RGLServerPlugin +) diff --git a/RGLVisualize/CMakeLists.txt b/RGLVisualize/CMakeLists.txt index 89a11b3..35dbaca 100644 --- a/RGLVisualize/CMakeLists.txt +++ b/RGLVisualize/CMakeLists.txt @@ -19,11 +19,17 @@ QT5_ADD_RESOURCES(resources_RCC RGLVisualize.qrc) add_library(RGLVisualize SHARED RGLVisualize.cc ${resources_RCC} - ) +) target_link_libraries(RGLVisualize PRIVATE ignition-gui6::ignition-gui6 ignition-rendering6::ignition-rendering6 ignition-msgs8::ignition-msgs8 - ) +) + +## Install libraries + +install(TARGETS RGLVisualize + DESTINATION RGLVisualize +)