ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Here's how I effectively segregated my cross-compile libs from my system libs.
My folder structure looks like this:
/path-to-cross-compiler-workspace/ros_catkin_ws
/path-to-cross-compiler-workspace/boost/boost_1.56.0
/path-to-cross-compiler-workspace/boost/boost_arm (install location for cross-compiled Boost)
/path-to-cross-compiler-workspace/usr/lib
/path-to-cross-compiler-workspace/usr/include
And my rostoolchain.cmake file looks like this:
# File: /path-to-cross-compiler-workspace/ros_catkin_ws/rostoolchain.cmake
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
set(CMAKE_FIND_ROOT_PATH /path-to-cross-compiler-workspace) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(BOOST_INCLUDEDIR /path-to-cross-compiler-workspace/boost/boost_arm/include)
set(BOOST_LIBRARYDIR /path-to-cross-compiler-workspace/boost/boost_arm/lib)
I found that using CMAKE_FIND_ROOT_PATH essentially treats whatever location you set it to as '/' in a typical system, so you want to populate this area with your libs and headers for your cross-compile target. So when cmake is looking for libraries, anything under /path-to-cross-compiler-workspace/usr/lib should be found automatically. This is just like if you are building a project for your local machine, and cmake can easily find libraries installed under /usr/lib.
Because I chose to install Boost in a non-standard location (i.e. next to my boost sources instead) I had to set the BOOST_INCLUDEDIR* and BOOST_LIBRARYDIR* cmake variables. I could have installed boost to /path-to-cross-compiler-workspace/usr, and it should be the same.
** My understanding is that these are the variables to use that tell cmake where to find boost, which is different than BOOST_INCLUDE_DIRS and BOOST_LIBRARY_DIRS, which are set by cmake after it finds boost.