cmake-policies(7)

Introduction

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 cmake_policy() command. It is also possible to request NEW, or non-backward compatible behavior for a policy, also avoiding the warning. Each policy can also be set to either NEW or OLD behavior explicitly on the command line with the CMAKE_POLICY_DEFAULT_CMP<NNNN> variable.

A policy is a deprecation mechanism and not a reliable feature toggle. A policy should almost never be set to OLD, except to silence warnings in an otherwise frozen or stable codebase, or temporarily as part of a larger migration path. The OLD behavior of each policy is undesirable and will be replaced with an error condition in a future release.

The cmake_minimum_required() 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 NEW behavior. To manage policies without increasing the minimum required CMake version, the if(POLICY) command may be used:

if(POLICY CMP0990)
  cmake_policy(SET CMP0990 NEW)
endif()

This has the effect of using the NEW 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 include() command or the find_package() command contain a use of cmake_policy(), that policy setting will not affect the caller by default. Both commands accept an optional NO_POLICY_SCOPE keyword to control this behavior.

The CMAKE_MINIMUM_REQUIRED_VERSION variable may also be used to determine whether to report an error on use of deprecated macros or functions.

Policies Introduced by CMake 3.24

Policies Introduced by CMake 3.23

Policies Introduced by CMake 3.22

Policies Introduced by CMake 3.21

Policies Introduced by CMake 3.20

Policies Introduced by CMake 3.19

Policies Introduced by CMake 3.18

Policies Introduced by CMake 3.17

Policies Introduced by CMake 3.16

Policies Introduced by CMake 3.15

Policies Introduced by CMake 3.14

Policies Introduced by CMake 3.13

Policies Introduced by CMake 3.12

Policies Introduced by CMake 3.11

Policies Introduced by CMake 3.10

Policies Introduced by CMake 3.9

Policies Introduced by CMake 3.8

Policies Introduced by CMake 3.7

Policies Introduced by CMake 3.4

Policies Introduced by CMake 3.3

Policies Introduced by CMake 3.2

Policies Introduced by CMake 3.1

Policies Introduced by CMake 3.0

Policies Introduced by CMake 2.8

Policies Introduced by CMake 2.6