[cmake-developers] Policy for INTERFACE_LINK_LIBRARIES

Stephen Kelly steveire at gmail.com
Thu Dec 6 17:00:43 EST 2012


Brad King wrote:

> On 12/06/2012 03:53 PM, Stephen Kelly wrote:
>> Brad King wrote:
>>> How can we ever stop exporting the old interface when it comes from the
>>> link implementation?
>> 
>> The approach I was thinking was to deal with it the same way we deal with
>> LINK_PUBLIC and LINK_PRIVATE - Make it depend on the policy.
> 
> The new interface is not exported unless the policy is NEW.  If the
> policy is NEW then the old interface is not exported.  Essentially the
> policy decides whether the link impl becomes the old or new interface,
> but never both.

Yes. 

> Now even projects that have never touched LINK_INTERFACE_LIBRARIES will
> have to be fixed to manually set it to a copy of the link implementation
> in order to remain compatible with older CMake versions once they set the
> policy to NEW.  I'm not currently sure whether this is okay.

Right. This recalls a fragment I was generating before in the Export* 
classes to issue a FATAL_ERROR if the policy is not set. Upstream would be 
deciding the minimum CMake version required by downstream. Do I understand 
you correctly? Is that the point which you are currently not sure is okay?

> 
>>> Actually, how do
>>> we even handle this for cross-export target references that were added
>>> recently?
>> 
>> I have not looked into that yet, but I don't think it's related to this.
>> 
>>  install(EXPORT fooTargets NAMESPACE foo_ ...)
>>  install(EXPORT barTargets NAMESPACE bar_ ...)
>> 
>> should not be affected by this. Or do you have a case in mind where it
>> could be? Or is that not the case you are thinking of?
> 
> If some of barTargets's exports depend on fooTarget's exports then
> the properties generated in barTargets that list those dependencies
> need to refer to fooTarget's imports with "foo_" rather than "bar_".
> I haven't checked if/how this currently works. 

Currently it doesn't seem to work. Using current master with this:

 add_library(picon SHARED libone.cpp)
 add_library(picoff SHARED libtwo.cpp)
 target_link_libraries(picoff picon)
 
 export(TARGETS
   picon
   NAMESPACE foo_
   FILE foo_iface.cmake
 )

 export(TARGETS
   picoff
   NAMESPACE bar_
   FILE bar_iface.cmake
 )

Results in an error:

 CMake Error at CMakeLists.txt:99 (export):
   export called with target "picoff" which requires target "picon" that is
   not in the export list.

   If the required target is not easy to reference in this call, consider
   using the APPEND option with multiple separate calls.


Yet the export files are created, and the bar_iface.cmake contains incorrect 
content:

 SET_TARGET_PROPERTIES(bar_picoff PROPERTIES
   IMPORTED_LINK_INTERFACE_LIBRARIES_NOCONFIG "bar_picon"

Note the wrong name for the bar_picon library.

> It needs to work in
> the new interfaces too.

If the existing stuff can be made work, we can revisit that then.

Thanks,

Steve.





More information about the cmake-developers mailing list