From 9df46977c4669039dddce9f41d130f1c72f1b493 Mon Sep 17 00:00:00 2001 From: gavanderhoorn Date: Sun, 12 Jan 2014 20:33:55 +0100 Subject: [PATCH] Work around simple_message not playing nice with Catkin. Test. --- industrial_robot_client/CMakeLists.txt | 7 ++++++- simple_message/CMakeLists.txt | 18 +++++++++++++++++- .../cmake/simple_message_linker_setup.cmake | 9 +++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 simple_message/cmake/simple_message_linker_setup.cmake diff --git a/industrial_robot_client/CMakeLists.txt b/industrial_robot_client/CMakeLists.txt index c9970f74..e9f3d979 100644 --- a/industrial_robot_client/CMakeLists.txt +++ b/industrial_robot_client/CMakeLists.txt @@ -30,7 +30,7 @@ catkin_package( simple_message actionlib_msgs actionlib urdf industrial_msgs industrial_utils INCLUDE_DIRS include -) +) @@ -38,6 +38,11 @@ include_directories(include ${catkin_INCLUDE_DIRS} ) + +# do some trickery with the linker for simple_message +simple_message_linker_setup() + + # This library depends on the simple_message library, which is available # in two formats to support endian differences between robot & PC. # diff --git a/simple_message/CMakeLists.txt b/simple_message/CMakeLists.txt index 2efdbf5b..590738a8 100644 --- a/simple_message/CMakeLists.txt +++ b/simple_message/CMakeLists.txt @@ -69,7 +69,9 @@ set(UTEST_SRC_FILES test/utest.cpp test/utest_message.cpp) catkin_package( CATKIN_DEPENDS roscpp industrial_msgs - INCLUDE_DIRS include + INCLUDE_DIRS include + LIBRARIES simple_message_dummy + CFG_EXTRAS simple_message_linker_setup.cmake ) @@ -77,6 +79,20 @@ include_directories(include ${catkin_INCLUDE_DIRS} ) + +# generate dummy library (we export it in catkin_package(..)), to force catkin +# to set up simple_message_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) +# 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}) + + # NOTE: All test files require TEST_PORT_BASE to be defined. Defining different # ports for each test executable allows them to run in parallel. diff --git a/simple_message/cmake/simple_message_linker_setup.cmake b/simple_message/cmake/simple_message_linker_setup.cmake new file mode 100644 index 00000000..7b72df66 --- /dev/null +++ b/simple_message/cmake/simple_message_linker_setup.cmake @@ -0,0 +1,9 @@ + +function(simple_message_linker_setup) + 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}) +endfunction()