Skip to content
This repository was archived by the owner on Dec 1, 2020. It is now read-only.

Commit cfb9659

Browse files
authored
Merge pull request #186 from project-march/fix/ethercat-grant
Fix ethercat_grant
2 parents 116cd85 + 9f4c842 commit cfb9659

File tree

3 files changed

+43
-11
lines changed

3 files changed

+43
-11
lines changed

march_hardware_interface/CMakeLists.txt

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,19 @@ catkin_package(
3333
roscpp
3434
std_msgs
3535
urdf
36+
CFG_EXTRAS
37+
${PROJECT_NAME}-extras.cmake
3638
)
3739

38-
set(ROSLINT_CPP_OPTS "--linelength=120")
39-
40-
file(GLOB_RECURSE lintfiles
41-
"include/*.h"
42-
"src/*.cpp"
43-
)
44-
45-
roslint_cpp(${lintfiles})
46-
40+
include(cmake/${PROJECT_NAME}-extras.cmake)
4741

4842
include_directories(include SYSTEM ${catkin_INCLUDE_DIRS})
4943

44+
# needed to circumvent LD_LIBRARY_PATH being emptied through ethercat_grant
45+
# in addition to not propagating march_hardware_interface RUNPATH to dependencies, in contrast to RPATH
46+
set(GCC_NEWDTAGS_LINK_FLAGS "-Wl,--disable-new-dtags")
47+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_NEWDTAGS_LINK_FLAGS}")
48+
5049
add_executable(${PROJECT_NAME}_node
5150
src/march_hardware_interface.cpp
5251
src/march_hardware_interface_node.cpp
@@ -55,6 +54,7 @@ add_executable(${PROJECT_NAME}_node
5554
add_dependencies(${PROJECT_NAME}_node ${catkin_EXPORTED_TARGETS})
5655

5756
target_link_libraries(${PROJECT_NAME}_node ${catkin_LIBRARIES})
57+
ros_enable_rpath(${PROJECT_NAME}_node)
5858

5959
install(DIRECTORY include/${PROJECT_NAME}/
6060
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
@@ -69,7 +69,7 @@ install(DIRECTORY config launch
6969
)
7070

7171
## Add gtest based cpp test target and link libraries
72-
if (CATKIN_ENABLE_TESTING)
72+
if(CATKIN_ENABLE_TESTING)
7373
find_package(code_coverage REQUIRED)
7474
find_package(rostest REQUIRED)
7575

@@ -92,4 +92,13 @@ if (CATKIN_ENABLE_TESTING)
9292
DEPENDS tests
9393
)
9494
endif()
95-
endif ()
95+
endif()
96+
97+
set(ROSLINT_CPP_OPTS "--linelength=120")
98+
99+
file(GLOB_RECURSE lintfiles
100+
"include/*.h"
101+
"src/*.cpp"
102+
)
103+
104+
roslint_cpp(${lintfiles})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# CMake function to add rpath to target
2+
# Copied from https://github.com/shadow-robot/ros_ethercat/blob/kinetic-devel/ros_ethercat_hardware/cmake/ros_ethercat_hardware-extras.cmake.em
3+
function(ros_enable_rpath target)
4+
# Set ${target} with RPATH built in so that we can install it suid
5+
set_target_properties(${target} PROPERTIES SKIP_BUILD_RPATH FALSE)
6+
7+
# Set the install RPATH to the install path
8+
set(RPATH "${CMAKE_INSTALL_PREFIX}/${CATKIN_PACKAGE_LIB_DESTINATION}")
9+
10+
# If LD_LIBRARY_PATH is set, add it to the install RPATH
11+
# this works in a normal catkin environment, but fails if the user unsets
12+
# their LD_LIBRARY_PATH manually for some reason
13+
if(DEFINED ENV{LD_LIBRARY_PATH})
14+
set(RPATH "${RPATH}:$ENV{LD_LIBRARY_PATH}")
15+
endif()
16+
17+
# Apply our computed RPATH to the target
18+
set_target_properties(${target} PROPERTIES INSTALL_RPATH ${RPATH})
19+
20+
# Don't use the final RPATH in devel space
21+
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH FALSE)
22+
endfunction()

march_hardware_interface/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
<exec_depend>robot_state_publisher</exec_depend>
3030
<exec_depend>xacro</exec_depend>
31+
<exec_depend>ethercat_grant</exec_depend>
3132

3233
<test_depend>rostest</test_depend>
3334
<test_depend>code_coverage</test_depend>

0 commit comments

Comments
 (0)