[cmake-developers] conditionals in generator expressions

Brad King brad.king at kitware.com
Mon Sep 24 08:49:26 EDT 2012


On 09/24/2012 04:42 AM, Stephen Kelly wrote:
>  get_target_property(loc tgt LOCATION)
>  get_target_property(loc tgt LOCATION_${Config})
[snip]
> It seems that the generator expressions for linked targets is in conflict 
> with the 'linker preference' feature. Is this a resolvable situation? 

That property has been extremely problematic because it's asking for info
that shouldn't be available until generate time.  This is far from the
first time it's caused trouble.

> The only option I see that might work is to extend the undefined behavior 
> documentation of the LOCATION* properties to cover use of generator 
> expressions with link libraries, and then try to refactor/copy the code out 
> of cmTarget to cmGeneratorTarget to add the generator expressions feature.

I think this limitation is perfectly acceptable.

Generator expressions should almost completely replace any need for the
LOCATION property.  We should eliminate from common use any code path that
needs the link language at configure time.  The export() command you brought
up in another thread may be the most difficult.

> The problem that would remain even then is that the maintainer of the build-
> system doesn't have full control.

...but can decide not to use the LOCATION properties ;)

> I wonder if it would work to introduce generator expression capable 
> LINK_LIBRARIES and INTERFACE_LINK_LIBRARIES properties

In the long run I think target_link_libraries should be reworked to maintain
a LINK_LIBRARIES target property, just as include_directories was switched
to the INCLUDE_DIRECTORIES target property.  The LINK_LIBRARIES property
would be the authoritative place and could be safely modified by other
commands like set_property.

> People porting to use the stuff would have to set the 
> LINK_LANGUAGE if they want a real LOCATION at configure-time.

IIRC the property is called LINKER_LANGUAGE, but yes.  When documenting
the above limitation on LOCATION with generator expressions, mention this
as a work around.

-Brad



More information about the cmake-developers mailing list