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.
Originally posted by gvdhoorn with karma: 86574 on 2016-09-04
This answer was ACCEPTED on the original site
Post score: 0
Original comments
Comment by Pototo on 2016-09-09:
I agree with the parameters suggestions. That will avoid recompilation every time
Comment by Pototo on 2016-09-12:
Actually, how do you create this in a config file by using appropriate project paths?
Comment by gvdhoorn on 2016-09-13:
The answer by @William I linked should show you an example.