[cmake-developers] CMake 2.8.12 transitive link regression?

Brad King brad.king at kitware.com
Thu Oct 31 14:43:07 EDT 2013


On 10/31/2013 01:13 PM, Stephen Kelly wrote:
> It is not obvious to the user that they are causing their downstreams to 
> depend on CMake 2.8.12. There was no warning about it (because there is no 
> bug in the code), no build error and no export error.
> 
> By populating INTERFACE_LINK_LIBRARIES instead, the result would be that 
> downstreams require 2.8.12. If that's what you want I can change this when 
> the policy is NEW. I think that's fine. If they care about their 
> downstreams, they'd test or examine their export files when they bump their 
> cmake version requirement.

This is already the case when using the keyword signatures:

 cmake_minimum_required(VERSION 2.8.12)
 project(FOO C)
 add_library(foo SHARED foo.c)
 target_link_libraries(foo LINK_PUBLIC z)
 export(TARGETS foo FILE myTargets.cmake)

No warning or error, and the export file only sets the new
INTERFACE_LINK_LIBRARIES property.  Once a project sets CMP0022
to NEW explicitly or by requiring 2.8.12 it is up to them to
make it work as desired.

We debated this extensively when first designing the policy and
reached this conclusion.  We just need to implement it correctly
for the plain tll signatures like it already is for the keyword
signatures.

> Or maybe I can export both INTERFACE_LINK_LIBRARIES and 
> IMPORTED_LINK_INTERFACE_LIBRARIES. But then, when could we ever not export 
> IMPORTED_LINK_INTERFACE_LIBRARIES?

That's why it's important to honor CMP0022==NEW and set the
INTERFACE_LINK_LIBRARIES on export, and set the old properties
only when explicitly requested by the new option.  Prior to your
proposed fix CMP0022==NEW would never export the old properties
without EXPORT_LINK_INTERFACE_LIBRARIES.

> Or we could make it a CMP0022-NEW-error to export a target which has link 
> dependencies and no explicit link interface and 
> EXPORT_LINK_INTERFACE_LIBRARIES is not used.

That will produce an error in the basic use case of plain tll sig
with export commands.  As explained above we already have the
silent bump in downstream requirement come from the bump in the
upstream requirement.  Also we can't introduce a new error case
in a tweak release.

The current error that suggests EXPORT_LINK_INTERFACE_LIBRARIES is
when someone explicitly sets the old LINK_INTERFACE_LIBRARIES
properties instead of using tll to do it.  When all link info comes
from tll we have enough information to know what to do.

cmExportFileGenerator::SetImportLinkInterface should never set
IMPORTED_LINK_INTERFACE_LIBRARIES when CMP0022 is NEW.  Currently
ImplementationIsInterface bypasses the policy check because it
assumes the policy check was already done in
cmTarget::ComputeLinkInterface before setting
ImplementationIsInterface to true.

I think what we need to do is when only the plain tll signature
is used, cmTarget and cmExportFileGenerator logic should behave
as if INTERFACE_LINK_LIBRARIES were always set to the link
implementation and LINK_INTERFACE_LIBRARIES is set to the link
implementation when CMP0022 is not NEW.

-Brad



More information about the cmake-developers mailing list