CMake/Catkin: How to export imported target
I have a pre-compiled shared library foo.so, and I'd like to wrap it in a catkin package for use by other catkin packages. So far I can accomplish all the linking issues if foo.so is in the same package as the targets that use it, but I am unable to get other packages to find the library externally. I have the following lines:
add_library(foo SHARED IMPORTED)
set_property(TARGET foo PROPERTY IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/lib/foo.so)
It compiles and runs great if in the same CMakeLists.txt I have something like:
add_library(bar src/bar.cpp}
target_link_libraries(bar
foo
${catkin_LIBRARIES}
)
But if I put this bar library in a different catkin package, it compiles fine but at runtime I get linking errors that then say missing symbols:
symbol lookup error: foo.so: undefined symbol
I have been researching and playing with adding things such as
set(${PROJECT_NAME}_EXPORTED_TARGETS foo)
or
export(TARGET foo)
But I'm really over my head. How do I export a pre-compiled shared library from one catkin package to another? I'm using catkin-tools.
Thanks!