Ask Your Question
0

add_definitions() Package Exportation

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

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 -0600

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 imagePototo ( 2016-09-09 11:43:58 -0600 )edit

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

Pototo gravatar imagePototo ( 2016-09-12 15:30:58 -0600 )edit

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

gvdhoorn gravatar imagegvdhoorn ( 2016-09-13 11:06:39 -0600 )edit

Your Answer

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

Add Answer

Question Tools

Stats

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

Seen: 162 times

Last updated: Sep 04 '16