ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

catkin export definitions

asked 2014-01-28 10:42:01 -0600

brice rebsamen gravatar image

packages that use PCL need to add those 2 lines in the CMakeLists:


Is there an option to pass those flags and apply them automatically to all packages that use PCL indirectly, by depending on a package that uses PCL?

e.g. let's a package A that uses PCL and so it has the 2 lines above in its CMakeLists, and a package B that uses package A, but does not use PCL directly. It's CMakeLists thus does not include those 2 lines.

I does not seem practical to request a package developer to check all the packages depended upon and check what flags they require... So I bet there is a solution...

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-01-28 11:52:07 -0600

brice rebsamen gravatar image

updated 2015-07-26 18:35:13 -0600

Based on dirk-thomas' answer, here is the complete solution for reference:

1- I created A/cmake/ with the following content:

# force automatic escaping of preprocessor definitions
cmake_policy(SET CMP0005 NEW)



2- I modified A's CMakeLists file as follow:

2.1- I added

CFG_EXTRAS A-extras.cmake

to the catkin_package() macro

2.2- I added


to A's CMakeLists.txt so that the definitions are used to build A itself

edit flag offensive delete link more


The last bit (2.2) should not be necessary: the cmake snippets exported in catkin_package(.. CFG_EXTRAS ..) are automatically included byt the dependent package. Unless of course you are including A-extras.cmake in A itself as well.

gvdhoorn gravatar image gvdhoorn  ( 2014-01-28 19:24:18 -0600 )edit

answered 2014-01-28 11:03:32 -0600

Dirk Thomas gravatar image

Your package can create a CMake extra file. That file is registered with catkin_package(CFG_EXTRAS ...) and will be included every time your package is find_packaged() by others.

As an example you can look at: and

May be the API doc will also help what you can actually pass as an argument and what kind of templates you can use:

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-01-28 10:42:01 -0600

Seen: 1,119 times

Last updated: Jul 26 '15