Sanchises
Sanchises

Reputation: 863

Specify custom include directory for library in rosmake (CMakeLists.txt)

For a ROS project, I need Boost 1.55, which is currently incompatible for use with ROS, so I can not install it alongside ROS. Since compiling ROS from source is not an option, I would like to change the directory where the compiler looks for Boost (instead of /usr/include/boost just my own directory).

So, if I have #include<boost/somefile.hpp>, I would like it to in fact include [package_folder]/include/boost/somefile.hpp; and this must of course also go for all the #include's in the Boost library itself. Is there an easy way of doing this (I think it should be done in the CMakeLists.txt file)

Here's what I tried (including what @ruslo suggested)

set(BOOST_ROOT include/boost_1_55_0)
find_package(Boost 1.55.0)

The boost status variables indicate that that went well, but then I still get

fatal error: boost/graph/successive_shortest_path_nonnegative_weights.hpp: No such file or directory

So, I listed all cmake variables that pointed to /usr/include/ and appended my Boost location:

set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/include;/usr/include)
set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/include;/usr/include)
set(GTEST_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include;/usr/include)

But to no avail. How do I get rosmake to get my directory?

Upvotes: 0

Views: 772

Answers (2)

Sanchises
Sanchises

Reputation: 863

The answer was easy. Added in CMakeLists.txt:

rosbuild_add_compile_flags(SingleImage "-std=c++0x")

include_directories(${PROJECT_SOURCE_DIR}/include/boost_1_55_0)

Which obviously I tried before, but that didn't work due to a 'dirty' build directory. So, always use rosmake yourpackage --target=clean... learned that the hard way.

Upvotes: 0

user2288008
user2288008

Reputation:

Just change BOOST_ROOT variable:

cmake -DBOOST_ROOT=/your/boost/location ...other options...

Upvotes: 1

Related Questions