Catkin library in Rosbuild package
Hi All,
UPDATE: I think I might have resolved the issue. I added the "find_package" and "target_link_library" to the rosbuild CMakeLists.txt
I'm in the process of migrating some of my packages from ROSBUILD to CATKIN. Unfortunately, I cannot migrate all of them at the moment. I have migrated a package that builds a library and now I cannot get the rosbuild package that depends on it to compile.
So, my question is: How do I include a library generated in a CATKIN package in a ROSBUILD package?
This is the CMakeList of the CATKIN package building a library:
cmake_minimum_required(VERSION 2.8.3)
project(catkin_library_package)
find_package(catkin REQUIRED COMPONENTS
roscpp
)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
###################################
## catkin specific configuration ##
###################################
catkin_package(
INCLUDE_DIRS include
LIBRARIES myCatkinLibrary
CATKIN_DEPENDS
roscpp
)
###########
## Build ##
###########
include_directories(
${catkin_INCLUDE_DIRS}
include
)
add_library(myCatkinLibrary myCatkinLibrary.cpp)
target_link_libraries(myCatkinLibrary
${catkin_LIBRARIES}
)
install(TARGETS myCatkinLibrary
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION})
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.hpp")
And the CMakeList of the Rosbuild package, which includes the library from the catkin package:
cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
SET(CMAKE_VERBOSE_MAKEFILE ON)
# The name of the project.
PROJECT(rosbuild_package)
rosbuild_find_ros_package(actionlib_msgs)
include(${actionlib_msgs_PACKAGE_PATH}/cmake/actionbuild.cmake)
find_package(catkin_library_package)
include_directories(${catkin_library_package_INCLUDE_DIRS})
genaction()
rosbuild_init()
set(LibraryList
${LibraryList}
)
rosbuild_add_boost_directories()
#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
rosbuild_genmsg()
rosbuild_add_executable(rosbuild_node src/main.cpp)
target_link_libraries(rosbuild_node ${catkin_library_package_LIBRARIES})
The CatkinLibraryPackage
contains (amongst other) /include/catkin_library_package/mylibrary.hpp
, which I'm trying to include in a ROSBUILD package.
The rosbuild_package contains /src/main.cpp
which specifies in the top: #include "catkin_library_package/myLibrary.hpp"
All names are substitutes.
The catkin package compiles fine, but when trying to compile the ROSBUILD package, it cannot find the mylibrary.hpp file (a header in the catkin package).
UPDATE: I've been trying to find the answer to the question before submitting the question here, but without luck. However, today I somehow came across this post. I added the find_package(CatkinLibraryPackage)
and the target_link_libraries(rosbuild_node ${CatkinLibraryPackage_LIBRARIES})
to the CMakeList of the ROSBUILD package. This way, I was able to get the rosbuild package to compile.
Any inputs on whether this is the correct way is appreciated...
Thanks to all for your input!
Best regards Casper
Everything seems fine in principle as you described it, but without any detailed information on what exactly you error messages, file layout, workspace layout and cmake files are it is impossible to figure out the problem.
As @dornhege says, this is a normal migration path. That does not make it simple, there are many details to handle: http://docs.ros.org/jade/api/catkin/h... .
I was hoping for a "quick" point to some obvious error I had made. Since not the case, I have now updated the question with some code. I have though found a solution in the mean while, but would of course will post the updated info as requested.
You might need to add the include directories too: CatkinLibraryPackage_INCLUDE_DIRS
I did that? It's right under the
find_package(...)
, if this is what you refer to...But you are right, that was indeed needed (perhaps the most important part in order to find the headers in the include folder)