[cmake-developers] Policy for INTERFACE_LINK_LIBRARIES

Brad King brad.king at kitware.com
Thu Nov 29 15:34:20 EST 2012


On 11/28/2012 05:15 PM, Stephen Kelly wrote:
>> I think we can drop the consumer-side policy completely.  Consumers will
>> load imported targets with the old and/or new interfaces specified as
>> chosen by the
>> producing project.
>>
>> CMake < 2.8.11 will just use the old interface.  CMake
>>> = 2.8.11 will just use the new interface if it is available and otherwise
>> fall
>> back to the old.  The burden of compatibility with existing consumer
>> releases falls on the authors modifying the producing project, just as
>> with any other change they make.
> 
> Yes.

Your revised commit:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8f77e068

still does more than the above.  ComputeImportInfo should not
check the policy at all because IMPORTED targets are always
consumer-side.

We've established the policy's behaviors for export() and
install(EXPORT).  We need to make behavior for linking by
consumers within the same project consistent.  Obviously such
cases will always be running CMake >= 2.8.11 so it will always
choose the new interface if it is defined.  Therefore when the
policy is not set to NEW we need to pretend that the new
interface is not defined.  In cmTarget::ComputeLinkInterface
you should not have a line like

  switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0019))

because that depends on the context at the end of the target's
directory processing rather than on when the target is created.
Instead, check the PolicyStatusCMP0019 member to decide whether
to read the old or new interface.  If the policy is not set then
read both, compare, warn if different, and use the old one.

Note that ComputeLinkInterface is the only place we need to have
the warning when the policy is not set.  It might not be called
on targets that are not exported or linked by another target in
the project, but in that case the link interface doesn't matter ;)

BTW, how do you plan to handle other parts of the link interface:

 - IMPORTED_LINK_INTERFACE_MULTIPLICITY
 - IMPORTED_LINK_INTERFACE_LANGUAGES
 - IMPORTED_LINK_DEPENDENT_LIBRARIES

?

Other comments on the commit ignoring the above discussion:

- The documentation is missing a period at the end of the NEW behavior
  sentence.  Also "the (IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?
  properties" would be better worded as "properties matching ..." to
  make it clear that the string is a regex for human reference.

- One CMP0019 warning hard-codes "LINK_INTERFACE_LIBRARIES" instead of
  the possible "LINK_INTERFACE_LIBRARIES_<CONFIG>" name.

Some documentation appears missing:

- Generator expressions BUILD_INTERFACE, INSTALL_INTERFACE, and
  EXPORT_NAMESPACE.

- Target property INTERFACE_LINK_LIBRARIES.

Thanks,
-Brad



More information about the cmake-developers mailing list