Policies in CMake are used to preserve backward compatible behavior
across multiple releases. When a new policy is introduced, newer CMake
versions will begin to warn about the backward compatible behavior. It
is possible to disable the warning by explicitly requesting the OLD, or
backward compatible behavior using the
It is also possible to request
, or non-backward compatible behavior
for a policy, also avoiding the warning. Each policy can also be set to
behavior explicitly on the command line with the
A policy is a deprecation mechanism and not a reliable feature toggle.
A policy should almost never be set to
, except to silence warnings
in an otherwise frozen or stable codebase, or temporarily as part of a
larger migration path. The
behavior of each policy is undesirable
and will be replaced with an error condition in a future release.
command does more than report an
error if a too-old version of CMake is used to build a project. It
also sets all policies introduced in that CMake version or earlier to
behavior. To manage policies without increasing the minimum required
CMake version, the
command may be used:
if(POLICY CMP0990) cmake_policy(SET CMP0990 NEW) endif()
This has the effect of using the
behavior with newer CMake releases which
users may be using and not issuing a compatibility warning.
The setting of a policy is confined in some cases to not propagate to the
parent scope. For example, if the files read by the
command contain a use of
that policy setting will not affect the caller by default. Both commands accept
keyword to control this behavior.
variable may also be used
to determine whether to report an error on use of deprecated macros or