[cmake-developers] Recommended way to get the definitions for a target ?

Brad King brad.king at kitware.com
Fri Sep 7 08:31:40 EDT 2012


On 09/06/2012 03:28 PM, Alexander Neundorf wrote:
> is there a recommended way to collect the preprocessor definitions for a target 
> ?
> From looking around it seems I have to manually collect COMPILE_DEFINITIONS 
> from the makefile, the target and the source file, and then again for each of 
> those additionally the per-configuration settings.

That is the only way now AFAIK.  You can survey how each generator
does it to be sure.  Note that they do not actually need to collect
everything in one place because the target-wide definitions and the
per-source definitions go in different places in the generated build
systems.

> Is this how it should be done, or is there a centralized function somewhere, 
> and if not, where should it be ?

Your description includes collecting them from a source file too.
This looks like you want the definitions for a cmSourceFile, not for
just a cmTarget.  A new internal API to collect the definitions would
need the cmTarget, cmSourceFile, and configuration name at least.  It
would probably go on cmGeneratorTarget if it is meant for use by the
generators.

-Brad



More information about the cmake-developers mailing list