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

Marcel Loose loose at astron.nl
Tue Aug 12 03:59:33 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
Hi,

Another problem I faced with policy CMP0022 is that I was unable to
really silence it. Setting the policy to OLD doesn't really work (at
least not in my case), maybe because the "cmake_policy()" command is
scoped(?). I have a macro that contains the now deprecated use of
LINK_INTERFACE_LIBRARIES, so I thought I could simply wrap that
statement inside the following code block:

    if (POLICY CMP0022)
        cmake_policy(PUSH)
        cmake_policy(SET CMP0022 OLD)
    endif()
    target_link_libraries (... LINK_INTERFACE_LIBRARIES ...)
    if (POLICY CMP0022)
        cmake_policy(POP)
    endif()

But that doesn't seem to work. I still get the policy warnings for
CMP0022. Also setting the policy to OLD once at top-level doesn't seem
to work; probably due to policy scoping. I played a bit with
NO_POLICY_SCOPE to different include() and find_package() statements,
but to no avail.

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/339f5773/attachment.vcf>


More information about the CMake mailing list