cmake-policies(7) — CMake 3.12.0 Documentation

# cmake-policies(7)

Contents

- cmake-policies(7)
  - Introduction
  - 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

## 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.12

- CMP0075: Include file check macros honor CMAKE_REQUIRED_LIBRARIES.
- CMP0074: find_package uses PackageName_ROOT variables.
- CMP0073: Do not produce legacy _LIB_DEPENDS cache entries.

## Policies Introduced by CMake 3.11

- CMP0072: FindOpenGL prefers GLVND by default when available.

## Policies Introduced by CMake 3.10

- CMP0071: Let AUTOMOC and AUTOUIC process GENERATED files.
- CMP0070: Define file(GENERATE) behavior for relative paths.

## Policies Introduced by CMake 3.9

- CMP0069: INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.
- CMP0068: RPATH settings on macOS do not affect install_name.

## Policies Introduced by CMake 3.8

- CMP0067: Honor language standard in try_compile() source-file signature.

## Policies Introduced by CMake 3.7

- CMP0066: Honor per-config flags in try_compile() source-file signature.

## Policies Introduced by CMake 3.4

- CMP0065: Do not add flags to export symbols from executables without the ENABLE_EXPORTS target property.
- CMP0064: Support new TEST if() operator.

## Policies Introduced by CMake 3.3

- CMP0063: Honor visibility properties for all target types.
- CMP0062: Disallow install() of export() result.
- CMP0061: CTest does not by default tell make to ignore errors (-i).
- CMP0060: Link libraries by full path even in implicit directories.
- CMP0059: Do not treat DEFINITIONS as a built-in directory property.
- CMP0058: Ninja requires custom command byproducts to be explicit.
- CMP0057: Support new IN_LIST if() operator.

## Policies Introduced by CMake 3.2

- CMP0056: Honor link flags in try_compile() source-file signature.
- CMP0055: Strict checking for break() command.

## Policies Introduced by CMake 3.1

- CMP0054: Only interpret if() arguments as variables or keywords when unquoted.
- CMP0053: Simplify variable reference and escape sequence evaluation.
- CMP0052: Reject source and build dirs in installed INTERFACE_INCLUDE_DIRECTORIES.
- CMP0051: List TARGET_OBJECTS in SOURCES target property.

## Policies Introduced by CMake 3.0

- CMP0050: Disallow add_custom_command SOURCE signatures.
- CMP0049: Do not expand variables in target source entries.
- CMP0048: project() command manages VERSION variables.
- CMP0047: Use QCC compiler id for the qcc drivers on QNX.
- CMP0046: Error on non-existent dependency in add_dependencies.
- CMP0045: Error on non-existent target in get_target_property.
- CMP0044: Case sensitive Lang_COMPILER_ID generator expressions.
- CMP0043: Ignore COMPILE_DEFINITIONS_Config properties.
- CMP0042: MACOSX_RPATH is enabled by default.
- CMP0041: Error on relative include with generator expression.
- CMP0040: The target in the TARGET signature of add_custom_command() must exist.
- CMP0039: Utility targets may not have link dependencies.
- CMP0038: Targets may not link directly to themselves.
- CMP0037: Target names should not be reserved and should match a validity pattern.
- CMP0036: The build_name command should not be called.
- CMP0035: The variable_requires command should not be called.
- CMP0034: The utility_source command should not be called.
- CMP0033: The export_library_dependencies command should not be called.
- CMP0032: The output_required_files command should not be called.
- CMP0031: The load_command command should not be called.
- CMP0030: The use_mangled_mesa command should not be called.
- CMP0029: The subdir_depends command should not be called.
- CMP0028: Double colon in target name means ALIAS or IMPORTED target.
- CMP0027: Conditionally linked imported targets with missing include directories.
- CMP0026: Disallow use of the LOCATION target property.
- CMP0025: Compiler id for Apple Clang is now AppleClang.
- CMP0024: Disallow include export result.

## Policies Introduced by CMake 2.8

- CMP0023: Plain and keyword target_link_libraries signatures cannot be mixed.
- CMP0022: INTERFACE_LINK_LIBRARIES defines the link interface.
- CMP0021: Fatal error on relative paths in INCLUDE_DIRECTORIES target property.
- CMP0020: Automatically link Qt executables to qtmain target on Windows.
- CMP0019: Do not re-expand variables in include and link information.
- CMP0018: Ignore CMAKE_SHARED_LIBRARY_Lang_FLAGS variable.
- CMP0017: Prefer files from the CMake module directory when including from there.
- CMP0016: target_link_libraries() reports error if its only argument is not a target.
- CMP0015: link_directories() treats paths relative to the source dir.
- CMP0014: Input directories must have CMakeLists.txt.
- CMP0013: Duplicate binary directories are not allowed.
- CMP0012: if() recognizes numbers and boolean constants.

## Policies Introduced by CMake 2.6

- CMP0011: Included scripts do automatic cmake_policy PUSH and POP.
- CMP0010: Bad variable reference syntax is an error.
- CMP0009: FILE GLOB_RECURSE calls should not follow symlinks by default.
- CMP0008: Libraries linked by full-path must have a valid library file name.
- CMP0007: list command no longer ignores empty elements.
- CMP0006: Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.
- CMP0005: Preprocessor definition values are now escaped automatically.
- CMP0004: Libraries linked may not have leading or trailing whitespace.
- CMP0003: Libraries linked via full path no longer produce linker search paths.
- CMP0002: Logical target names must be globally unique.
- CMP0001: CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.
- CMP0000: A minimum required CMake version must be specified.