From 241be2fb09c306350c02e5f907bf7ef9b0b8ce7e Mon Sep 17 00:00:00 2001 From: Yannick Goumaz <61198661+ygoumaz@users.noreply.github.com> Date: Fri, 23 Dec 2022 13:53:15 +0100 Subject: [PATCH] Remove symlinks and add shared libs to rpath (#572) --- webots_ros2_driver/CMakeLists.txt | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/webots_ros2_driver/CMakeLists.txt b/webots_ros2_driver/CMakeLists.txt index 9cf890b7b..5f0719a4b 100644 --- a/webots_ros2_driver/CMakeLists.txt +++ b/webots_ros2_driver/CMakeLists.txt @@ -12,6 +12,7 @@ endif() set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) # Check which ROS distribution is used, vision_msgs depends of that if($ENV{ROS_DISTRO} MATCHES "foxy") @@ -85,6 +86,8 @@ ament_python_install_package(vehicle ament_python_install_package(${PROJECT_NAME} PACKAGE_DIR ${PROJECT_NAME}) +# Driver +set(CMAKE_INSTALL_RPATH "$ORIGIN/../controller") add_executable(driver src/Driver.cpp src/WebotsNode.cpp @@ -100,8 +103,6 @@ add_executable(driver src/utils/Math.cpp src/utils/Utils.cpp ) - -# Driver ament_target_dependencies(driver rosgraph_msgs rclcpp @@ -131,6 +132,7 @@ install(TARGETS driver ) # Dynamic IMU +set(CMAKE_INSTALL_RPATH "$ORIGIN/controller") add_library( ${PROJECT_NAME}_imu SHARED @@ -179,18 +181,6 @@ install( PATTERN "*CppDriver*" ) -# Create symlinks of libController -macro(lib_symlink filename) - install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_INSTALL_PREFIX}/lib/controller/${filename} ${CMAKE_INSTALL_PREFIX}/lib/${filename})") -endmacro(lib_symlink) - -lib_symlink(libController.so) -lib_symlink(libcar.so) -lib_symlink(libCppCar.so) -lib_symlink(libCppController.so) -lib_symlink(libCppDriver.so) -lib_symlink(libdriver.so) - # Prevent pluginlib from using boost target_compile_definitions(driver PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS") target_compile_definitions(${PROJECT_NAME}_imu PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS") @@ -208,6 +198,15 @@ install( ) # Ament export +set(WEBOTS_LIB_PATH + controller/${CMAKE_SHARED_LIBRARY_PREFIX}Controller${CMAKE_SHARED_LIBRARY_SUFFIX} + controller/${CMAKE_SHARED_LIBRARY_PREFIX}CppController${CMAKE_SHARED_LIBRARY_SUFFIX} + controller/${CMAKE_SHARED_LIBRARY_PREFIX}driver${CMAKE_SHARED_LIBRARY_SUFFIX} + controller/${CMAKE_SHARED_LIBRARY_PREFIX}CppDriver${CMAKE_SHARED_LIBRARY_SUFFIX} + controller/${CMAKE_SHARED_LIBRARY_PREFIX}car${CMAKE_SHARED_LIBRARY_SUFFIX} + controller/${CMAKE_SHARED_LIBRARY_PREFIX}CppCar${CMAKE_SHARED_LIBRARY_SUFFIX} +) + ament_export_include_directories( include include/webots/c @@ -227,6 +226,6 @@ ament_export_dependencies( ) ament_export_libraries( ${PROJECT_NAME}_imu - ${WEBOTS_LIB} + ${WEBOTS_LIB_PATH} ) ament_package()