cmake-policies(7) — CMake 4.0.1 Documentation (original) (raw)

Contents

Introduction

CMake policies introduce behavior changes while preserving compatibility for existing project releases. Policies are deprecation mechanisms, not feature toggles. Each policy documents a deprecated OLD behavior and a preferred NEW behavior. Projects must be updated over time to use the NEW behavior, but their existing releases will continue to work with the OLD behavior.

Updating Projects

When policies are newly introduced by a version of CMake, their OLDbehaviors are immediately deprecated by that version of CMake and later. Projects should be updated to use the NEW behaviors of the policies as soon as possible.

Use the cmake_minimum_required() command to record the latest version of CMake for which a project has been updated. For example:

cmake_minimum_required(VERSION 3.10...3.31)

This uses the <min>...<max> syntax to enable the NEW behaviors of policies introduced in CMake 3.31 and earlier while only requiring a minimum version of CMake 3.10. The project is expected to work with both the OLD and NEW behaviors of policies introduced between those versions.

Transition Schedule

To help projects port to the NEW behaviors of policies on their own schedule, CMake offers a transition period:

Supported Policies

The following policies are supported.

Policies Introduced by CMake 4.0

Policies Introduced by CMake 3.31

Policies Introduced by CMake 3.30

Policies Introduced by CMake 3.29

Policies Introduced by CMake 3.28

Policies Introduced by CMake 3.27

Policies Introduced by CMake 3.26

Policies Introduced by CMake 3.25

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

Unsupported Policies

The following policies are no longer supported. Projects' calls to cmake_minimum_required(VERSION) orcmake_policy(VERSION) must set them to NEW. Their OLD behaviors have been removed from CMake.

Policies Introduced by CMake 3.4, Removed by CMake 4.0

Policies Introduced by CMake 3.3, Removed by CMake 4.0

Policies Introduced by CMake 3.2, Removed by CMake 4.0

Policies Introduced by CMake 3.1, Removed by CMake 4.0

Policies Introduced by CMake 3.0, Removed by CMake 4.0

Policies Introduced by CMake 2.8, Removed by CMake 4.0

Policies Introduced by CMake 2.6, Removed by CMake 4.0