Skip to content

Commit

Permalink
Remove symlinks and add shared libs to rpath (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
ygoumaz authored Dec 23, 2022
1 parent 6a94cc8 commit 241be2f
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions webots_ros2_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -100,8 +103,6 @@ add_executable(driver
src/utils/Math.cpp
src/utils/Utils.cpp
)

# Driver
ament_target_dependencies(driver
rosgraph_msgs
rclcpp
Expand Down Expand Up @@ -131,6 +132,7 @@ install(TARGETS driver
)

# Dynamic IMU
set(CMAKE_INSTALL_RPATH "$ORIGIN/controller")
add_library(
${PROJECT_NAME}_imu
SHARED
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -227,6 +226,6 @@ ament_export_dependencies(
)
ament_export_libraries(
${PROJECT_NAME}_imu
${WEBOTS_LIB}
${WEBOTS_LIB_PATH}
)
ament_package()

0 comments on commit 241be2f

Please sign in to comment.