[CMake] How to deal with incompatible changes in interface of target_link_libraries()?

Marcel Loose loose at astron.nl
Tue Aug 12 03:48:17 EDT 2014


On 11/08/14 18:47, Brad King wrote:
> On 08/09/2014 09:46 AM, Marcel Loose wrote:
>> CMake 2.8.12 introduced the keywords PRIVATE, INTERFACE and PUBLIC, and
>> immediately deprecated the LINK_INTERFACE_LIBRARIES keyword,
>> triggering policy warnings CMP0022 and CMP0023.
>>
>> What is the proper way to get rid of these policy warnings, while at
>> the same time staying backward compatible with older CMake versions?
> From the documentation of CMP0022:
>
>  "Warning-free future-compatible code which works with CMake 2.8.9
>   onwards can be written by using the LINK_PRIVATE and LINK_PUBLIC
>   keywords of target_link_libraries()."
>
> Actually it should say 2.8.7, not 2.8.9.  CMP0023 docs mention 2.8.7.
>
> -Brad
Hmm,

That's probably in the CMake 3.0.x docs; CMake 2.8.12 doesn't mention
LINK_PUBLIC and LINK_PRIVATE in the policy documentation. I only read
the following in the docs on target_link_libraries

       The LINK_PUBLIC and LINK_PRIVATE modes can be used to specify
both the
       link dependencies and the link interface in one command.  This
       signature is for compatibility only.  Prefer the PUBLIC or PRIVATE
       keywords instead. 

"... for compatibility only" didn't give me the feeling that this is the
way to go, which is underscored by the next sentence: "Prefer the ..."

On a side note. Even using the new PRIVATE and PUBLIC keywords I am
unable to exactly specify which libraries are needed for linking.
Without breaking builds with static libraries, I am forced to specify
too many library dependencies. Maybe I'm doing something wrong, but my
setup is quite complicated. Fortunately, modern version of ld will get
rid of unused libraries anyway, so it's not really that much of an issue
for me.

Regards,
Marcel Loose.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: loose.vcf
Type: text/x-vcard
Size: 292 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140812/76a8aedb/attachment.vcf>


More information about the CMake mailing list