ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One strategy would be to calculate the relative path to the library on installation and then add it explicitly to the ${crossing_detector_LIBRARIES} variable using a CMake extra's file. The extra's file would look something like this:

# generated from the cmake/crossing_detector-extras.cmake.in file

# Calculate the path to the library
find_library(crossing_detector_wrapper_cpp_library NAMES crossing_detector_wrapper_cpp PATHS "${crossing_detector_DIR}/../../../@CATKIN_GLOBAL_LIB_DESTINATION@/" NO_DEFAULT_PATH)

# I think this next part will work, but it is optional.
# If you don't include it then dependent packages
# will need to use the crossing_detector_wrapper_cpp_library explicitly.
list(APPEND crossing_detector_LIBRARIES ${crossing_detector_wrapper_cpp_library})

So you'd use find_library so that it handles the library prefix and suffix correctly, but if you messed with the library name (it looks like you did) then you may need to do something slightly different, see the find_library docs:

http://www.cmake.org/cmake/help/v3.0/command/find_library.html

Additionally you'll need to do this in your CMakeLists.txt to get that file expanded and installed into the devel space and install space:

catkin_package(...
CFG_EXTRAS crossing_detector-extras.cmake
...)

Also, I _think_ you can safely extend the crossing_detector_LIBRARIES variable at this point, maybe @Dirk Thomas can chime in on that. However, if not you will need to explicitly use the crossing_detector_wrapper_cpp_library variable in downstream packages after calling find_package(... crossing_detector ...). Something like this:

find_package(catkin REQUIRED COMPONENTS crossing_detector ...)

add_executable(foo ...)
target_link_libraries(foo ${catkin_LIBRARIES} ${crossing_detector_wrapper_cpp_library})