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

Brad King brad.king at kitware.com
Tue Feb 19 15:34:49 EST 2013


Steve,

I think this may fall under your expertise now.  The goal is to generate
a nice error message when an imported target's link interface depends on
other targets that should have been imported but have not been.  Currently
we just get a build-time link failure because the name is treated as a
plain library name.  We'd like a generate-time error message with as much
context as possible instead.

On 02/19/2013 02:57 PM, Alexander Neundorf wrote:
> On Tuesday 19 February 2013, Brad King wrote:
>> On 02/18/2013 08:23 AM, Brad King wrote:
>>> Another approach is to just add an extra property to imported targets
>>> that list their dependencies that are expected to be targets.  If when
>>> following the link interface out of that target and a library name is
>>> not a target, check the extra property on the very same target to see
>>> if it should have been one.
>>
>> Any comment on this idea?  It may be simpler to implement and produce
>> better error messages.
> 
> I had the same idea, but went with the directory property first.
> The target property would avoid any scope-issues, it looks quite elegant.

Yes.

> I haven't worked on the link-dependency-calculation much, so I wasn't sure how 
> this code exactly works, so I went with the (for me) easier way, checking 
> directly in FindTargetToUse().
> 
> Can you give me a pointer where the member of the link interface are checked ?

I just looked at this and I take back the part about being easier to
implement.  However I still think the approach is better and will
allow us to produce better error messages.

I think what we need is for the cmTarget::LinkInterface structure
to have a new "TargetNames" member populated by ComputeLinkInterface
from a new "INTERFACE_TARGET_DEPENDS" property (better names?).
On export of the link interfaces the net collection of target names
that refer to targets imported by the exporting project should be
put in this property.  Then cmComputeLinkDepends can complain when
following the link interface and a library with one of these names
cannot be found as a target.

Comments?
-Brad



More information about the cmake-developers mailing list