export a prebuilt library in catkin
I am wondering how can I export an already built library within a package to make it available to other catkin packages.
Before with rosbuild this could be done by by using the cpp tag in the manifest. For instance:
<export>
<cpp lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/lib -lmylib" cflags="-I${prefix}/include"/>
</export>
As far as I understand this functionality has been replaced by the catkin_package() command. However, I have not found a clear way to make a prebuilt library within a catkin package visible to other catkin packages.
I have tried setting the prebuilt library as an imported library, but then when I do cmake it does not set it as a target visible by other packages. In CMakeLists.txt I have:
...
catkin_package(LIBRARIES mylib)
...
add_library(mylib STATIC IMPORTED)
set_target_properties(mylib PROPERTIES IMPORTED_LOCATION /path/to/mylib)
Any suggestions?
catkin_package(LIBRARIES ...) should be able to handle libraries build in your cmake project, absolute paths to an existing library as well as imported library targets. Please consider providing a link to the sources for further investigation.
The package in question can be found in https://github.com/kth-ros-pkg/kvaser_canlib.git I managed to get it working, but I had to do a hard copy of the library to the devel/lib folder. Any suggestions on how to do this in a more clean way?