ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

How to export non-standard include directories in catkin?

asked 2013-10-22 10:59:52 -0600

dustingooding gravatar image

updated 2014-01-28 17:18:19 -0600

ngrennan gravatar image

This question spawned from question 68680.

I'm using yujin_tools to cross-compile ROS for ARM. I've created a Catkin package for tinyxml that installs headers to <sysroot-prefix>/include/tinyxml, and the package advertises "include" and "include/tinyxml" in the catkin_package() macro.

When I build rospack, it complains about not finding the tinyxml.h header:

/home/user/ros_yujin_ws/src/rospack/src/rospack.cpp:30: fatal error: tinyxml.h: No such file or directory

rospack is using the non-namespaced version of the tinyxml include directive, but I've installed them namespaced. How do I tell rospack to look in <prefix>/include/tinyxml instead of or in addition to <prefix>/include?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-10-22 11:29:22 -0600

William gravatar image

updated 2017-11-27 09:35:40 -0600

gvdhoorn gravatar image

So catkin makes the assumption that you install all of your headers into the root of the include folder, i.e. <prefix>/include, when generating your CMake config file and pkg-config files. So your resulting pkg_name_INCLUDE_DIRS will by default be <prefix>/include. In this instance you want to have that also include <prefix>/include/pkg_name as well.

There are two ways to accomplish this. The first is simple, but will break if you relocate the installed package.

Simply pass this to your catkin_package(...) call:

  INCLUDE_DIRS include include/tinyxml ${CMAKE_INSTALL_PREFIX}/include/tinyxml

The second way uses the pkg_name_DIR variable which allows you to make a relocatable addition to your _INCLUDE_DIRS. The problem is that this variable is not available in your CMakeLists.txt, but is available when your package is find_package'ed, so you have to use a CMake extras file (which gets evaluated at find_package time) in order to do this correctly.

Reference: ( CFG_EXTRAS)

In order to do this, what you will want to do is to is create a file in your project cmake/<pkg_name> where you replace <pkg_name> with your package name. In that file you should do something like this:


The elements inside of @..@ will get templated at build time of your package. You will need to tell catkin to do this templating for you:

  CFG_EXTRAS <pkg_name>-extras.cmake

Note that you do not include the .in extension here.

edit flag offensive delete link more



@Dirk Thomas please review this answer

William gravatar image William  ( 2013-10-22 11:31:32 -0600 )edit

Looks all good to me. Great answer.

Dirk Thomas gravatar image Dirk Thomas  ( 2013-10-22 11:39:11 -0600 )edit

When doing this for a package to be released, should the <pkg_name>-extras.cmake file be installed? I'm guessing yes.

hawesie gravatar image hawesie  ( 2014-10-28 11:16:12 -0600 )edit

When you use CFG_EXTRAS the file gets installed automatically.

Dirk Thomas gravatar image Dirk Thomas  ( 2014-10-28 11:55:57 -0600 )edit

Awesome, thanks.

hawesie gravatar image hawesie  ( 2014-10-28 14:23:03 -0600 )edit

Question Tools

1 follower


Asked: 2013-10-22 10:59:52 -0600

Seen: 4,415 times

Last updated: Nov 27 '17