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

add_definitions() Package Exportation

asked 2016-09-02 14:23:31 -0500

Pototo gravatar image

Folks,

I have some variables I declared in my CMakeList in one package. For example, I create the constant:

add_definitions(-DTRAINED_DATA_PATH="${PROJECT_SOURCE_DIR}/trained_data")

How can I make it available to other ROS packages?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-09-04 04:21:14 -0500

gvdhoorn gravatar image

You'll want to look into Catkin's CFG_EXTRA feature.

See How to export non-standard include directories in catkin? for an answer by @William that explains how to do this (this deals with include directories specifically, but the principle is the same. Just place an add_definitions(..) in your extras file, and be careful with PROJECT_SOURCE_DIR, as it may not have the same value (or be even defined) in the devel and install spaces).

Btw: using (ROS) parameters is a bit more flexible than using hard-coded, compile time constants, as it allows you to specify the location of things using a bit of configuration. That would also remove the need for exporting the define. If you have the option (ie: this is not a completely stand-alone library that is supposed to work without ROS), I'd use that.

edit flag offensive delete link more

Comments

I agree with the parameters suggestions. That will avoid recompilation every time

Pototo gravatar image Pototo  ( 2016-09-09 11:43:58 -0500 )edit

Actually, how do you create this in a config file by using appropriate project paths?

Pototo gravatar image Pototo  ( 2016-09-12 15:30:58 -0500 )edit

The answer by @William I linked should show you an example.

gvdhoorn gravatar image gvdhoorn  ( 2016-09-13 11:06:39 -0500 )edit

Question Tools

Stats

Asked: 2016-09-02 14:23:31 -0500

Seen: 516 times

Last updated: Sep 04 '16