[cmake-developers] Setting target properties before the target is defined ?

Alexander Neundorf neundorf at kde.org
Fri Feb 15 17:54:05 EST 2013


On Friday 15 February 2013, Brad King wrote:
> On 02/15/2013 04:37 PM, Alexander Neundorf wrote:
> > So is it possible to refer to not-yet-defined targets from tll(), and
> > what happens if they get not defined later on ?
> 
> This works at it always has.  If the named item does not resolve to a
> target name at generate time it is treated as a raw library (-lfoo).
> If it does resolve to a target then now the usage requirements will
> be applied from its interface properties.  The decision now occurs
> at generate time.

The thing is, if I generate an error at configure time if at the end of a 
directory a target has been used but has not been defined, i.e. a target Foo 
has been imported which links against a missing imported target, it would 
still be possible that the project can build successfully if this bad imported 
target Foo is simply not used, e.g. because Foo_FOUND is set to FALSE.

How about that: when in the exported and then imported Target.cmake a used 
target is not yet defined, this target name is added to a cmake variable.
When then cmake calculates the linking, and it can't find a target, it checks 
whether the name is contained in this cmake variable.
If so, it errors out instead of assuming it is the name of a library.

Does that sound reasonable, and better than failing already earlier ?

Alex



More information about the cmake-developers mailing list