Skip to content

Commit

Permalink
robot_client: workaround for ros-industrial#46. Fix ros-industrial#67.
Browse files Browse the repository at this point in the history
This is an updated version of the workaround committed in 9df4697. Instead
of requiring dependent packages to invoke the function defined in the
CFG_EXTRAS cmake snippet, the snippet now sets up the linker path directly.

Dependent packages now only need to remember to explicitly list their
dependency on `industrial_robot_client` and `simple_message` in their
`add_library(..)` statements.
  • Loading branch information
gavanderhoorn authored and shaun-edwards committed Jan 21, 2014
1 parent 85540e3 commit a1c9b6a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 18 deletions.
15 changes: 13 additions & 2 deletions industrial_robot_client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ catkin_package(
simple_message actionlib_msgs actionlib urdf industrial_msgs
industrial_utils
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}_dummy
CFG_EXTRAS issue46_workaround.cmake
)


Expand All @@ -39,8 +41,17 @@ include_directories(include
)


# do some trickery with the linker for simple_message
simple_message_linker_setup()
# generate dummy library (we export it in catkin_package(..)), to force catkin
# to set up LIBRARY_DIRS properly.
# TODO: find out if LIBRARY_DIRS can be exported without dummy library target
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_dummy.cpp
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_dummy.cpp)
add_library(${PROJECT_NAME}_dummy ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_dummy.cpp)
# unfortunately this will have to be installed, but the linker will remove it
# from the library dependencies of dependent targets, as it contains no symbols
# that can be imported from it.
install(TARGETS ${PROJECT_NAME}_dummy DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})


# This library depends on the simple_message library, which is available
Expand Down
10 changes: 10 additions & 0 deletions industrial_robot_client/cmake/issue46_workaround.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Temporary workaround for issue ros-industrial/industrial_core#46.
#
message(STATUS "industrial_robot_client: work around for #46")
if (DEFINED industrial_robot_client_LIBRARY_DIRS)
else()
message(FATAL_ERROR "industrial_robot_client_LIBRARY_DIRS not set, "
"have you find_package()-ed it?")
endif()
link_directories(${industrial_robot_client_LIBRARY_DIRS})
14 changes: 7 additions & 7 deletions simple_message/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ set(UTEST_SRC_FILES test/utest.cpp test/utest_message.cpp)
catkin_package(
CATKIN_DEPENDS roscpp industrial_msgs
INCLUDE_DIRS include
LIBRARIES simple_message_dummy
CFG_EXTRAS simple_message_linker_setup.cmake
LIBRARIES ${PROJECT_NAME}_dummy
CFG_EXTRAS issue46_workaround.cmake
)


Expand All @@ -81,16 +81,16 @@ include_directories(include


# generate dummy library (we export it in catkin_package(..)), to force catkin
# to set up simple_message_LIBRARY_DIRS properly.
# to set up LIBRARY_DIRS properly.
# TODO: find out if LIBRARY_DIRS can be exported without dummy library target
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/simple_message_dummy.cpp
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/simple_message_dummy.cpp)
add_library(simple_message_dummy ${CMAKE_CURRENT_BINARY_DIR}/simple_message_dummy.cpp)
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_dummy.cpp
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_dummy.cpp)
add_library(${PROJECT_NAME}_dummy ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_dummy.cpp)
# unfortunately this will have to be installed, but the linker will remove it
# from the library dependencies of dependent targets, as it contains no symbols
# that can be imported from it.
install(TARGETS simple_message_dummy DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
install(TARGETS ${PROJECT_NAME}_dummy DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})


# NOTE: All test files require TEST_PORT_BASE to be defined. Defining different
Expand Down
10 changes: 10 additions & 0 deletions simple_message/cmake/issue46_workaround.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Temporary workaround for issue ros-industrial/industrial_core#46.
#
message(STATUS "simple_message: work around for #46")
if (DEFINED simple_message_LIBRARY_DIRS)
else()
message(FATAL_ERROR "simple_message_LIBRARY_DIRS not set, "
"have you find_package()-ed it?")
endif()
link_directories(${simple_message_LIBRARY_DIRS})
9 changes: 0 additions & 9 deletions simple_message/cmake/simple_message_linker_setup.cmake

This file was deleted.

0 comments on commit a1c9b6a

Please sign in to comment.