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

Brad King brad.king at kitware.com
Tue Aug 12 09:06:13 EDT 2014


On 08/12/2014 03:59 AM, Marcel Loose wrote:
> 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(?).

For CMP0022 and CMP0023 the policy setting is recorded on each target
when it is created by and add_library command.  That affects all
target_link_libraries calls that give the library as the first argument.

> setting the policy to OLD once at top-level doesn't seem to work

Any call to cmake_minimum_required(VERSION) will unset policies
introduced in versions larger than that named.

FYI, the only intended use case for setting a policy to OLD is to
quiet warnings in a maintenance branch of an existing release.
Some day support for OLD behavior of some policies may be dropped,
so all project development moving forward should set the policy
to NEW.

-Brad



More information about the CMake mailing list