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

Brad King brad.king at kitware.com
Wed Feb 20 08:31:18 EST 2013


On 02/20/2013 03:44 AM, Stephen Kelly wrote:
> Brad King wrote:
>> 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.
>>
> I may have missed something, but I've pushed a missing-imported-targets-
> error branch to my clone which is quite simple. I haven't put a lot of 
> thought into it. It's just a proof of concept.

Wonderful start.  Thanks for working on it.

Alex, does this do what you want?

As for the implementation itself:

+    // TODO: The link interface is config-dependent, so possibly this should
+    // be too.

Yes.  However, how will this tie into a future INTERFACE_LINK_LIBRARIES?
Perhaps at that time we can use $<TARGET_NAME:...> to know that names
should be targets since the property value won't have to work with
older CMake versions.  For now let's call it something like

 IMPORTED_LINK_INTERFACE_TARGETS_<CONFIG>

instead of INTERFACE_TARGET_DEPENDS.  It makes sense only for imported
targets anyway.  It should be documented for use only in producing this
error message and have no other effects.

For the error message:

+          e << "The target " << this->GetName() << " depends on the "
+               "IMPORTED target " << *li << ", which does not exist.";

let's make it clear that the target *expects* the name to be an imported
target.  Something like:

 Imported target "<a>" expects a target "<b>" to be imported, but
 no such imported target exists.

Thanks,
-Brad



More information about the cmake-developers mailing list