cmake-policies(7)¶
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 OLD
behaviors 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...4.0)
This uses the <min>...<max>
syntax to enable the NEW
behaviors
of policies introduced in CMake 4.0 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:
If a policy is not set by a project, CMake uses its
OLD
behavior, but may warn that the policy has not been set.Users running CMake may silence the warning without modifying a project by setting the
CMAKE_POLICY_DEFAULT_CMP<NNNN>
variable as a cache entry on thecmake(1)
command line:cmake -DCMAKE_POLICY_DEFAULT_CMP0990=OLD ...
Projects may silence the warning by using the
cmake_policy()
command to explicitly set the policy toOLD
orNEW
behavior:if(POLICY CMP0990) cmake_policy(SET CMP0990 NEW) endif()
Note
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.
If a policy is set to
OLD
by a project, CMake versions released at least 2 years after the version that introduced a policy may issue a warning that the policy'sOLD
behavior will be removed from a future version of CMake.If a policy is not set to
NEW
by a project, CMake versions released at least 6 years after the version that introduced a policy, and whose major version number is higher, may issue an error that the policy'sOLD
behavior has been removed.
Supported Policies¶
The following policies are supported.
Policies Introduced by CMake 4.1¶
- CMP0190: FindPython enforce consistency in cross-compiling mode.
- CMP0189: TARGET_PROPERTY evaluates LINK_LIBRARIES properties transitively.
- CMP0188: The FindGCCXML module is removed.
- CMP0187: Include source file without an extension after the same name with an extension.
- CMP0186: Regular expressions match ^ at most once in repeated searches.
Policies Introduced by CMake 4.0¶
- CMP0185: FindRuby no longer provides upper-case RUBY_* variables.
- CMP0184: MSVC runtime checks flags are selected by an abstraction.
- CMP0183: add_feature_info() supports full Condition Syntax.
- CMP0182: Create shared library archives by default on AIX.
- CMP0181: Link command-line fragment variables are parsed and re-quoted.
Policies Introduced by CMake 3.31¶
- CMP0180: project() always sets <PROJECT-NAME>_* as normal variables.
- CMP0179: De-duplication of static libraries on link lines keeps first occurrence.
- CMP0178: Test command lines preserve empty arguments.
- CMP0177: install() DESTINATION paths are normalized.
- CMP0176: execute_process() ENCODING is UTF-8 by default.
- CMP0175: add_custom_command() rejects invalid arguments.
- CMP0174: cmake_parse_arguments(PARSE_ARGV) defines a variable for an empty string after a single-value keyword.
- CMP0173: The CMakeFindFrameworks module is removed.
- CMP0172: The CPack module enables per-machine installation by default in the CPack WIX Generator.
- CMP0171: 'codegen' is a reserved target name.
Policies Introduced by CMake 3.30¶
- CMP0170: FETCHCONTENT_FULLY_DISCONNECTED requirements are enforced.
- CMP0169: FetchContent_Populate(depName) single-argument signature is deprecated.
- CMP0168: FetchContent implements steps directly instead of through a sub-build.
- CMP0167: The FindBoost module is removed.
- CMP0166: TARGET_PROPERTY evaluates link properties transitively over private dependencies of static libraries.
- CMP0165: enable_language() must not be called before project().
- CMP0164: add_library() rejects SHARED libraries when not supported by the platform.
- CMP0163: The GENERATED source file property is now visible in all directories.
- CMP0162: Visual Studio generators add UseDebugLibraries indicators by default.
Policies Introduced by CMake 3.29¶
- CMP0161: CPACK_PRODUCTBUILD_DOMAINS defaults to true.
- CMP0160: More read-only target properties now error when trying to set them.
- CMP0159: file(STRINGS) with REGEX updates CMAKE_MATCH_<n>.
- CMP0158: add_test() honors CMAKE_CROSSCOMPILING_EMULATOR only when cross-compiling.
- CMP0157: Swift compilation mode is selected by an abstraction.
- CMP0156: De-duplicate libraries on link lines based on linker capabilities.
Policies Introduced by CMake 3.28¶
- CMP0155: C++ sources in targets with at least C++20 are scanned for imports when supported.
- CMP0154: Generated files are private by default in targets using file sets.
- CMP0153: The exec_program command should not be called.
- CMP0152: file(REAL_PATH) resolves symlinks before collapsing ../ components.
Policies Introduced by CMake 3.27¶
- CMP0151: AUTOMOC include directory is a system include directory by default.
- CMP0150: ExternalProject_Add and FetchContent_Declare treat relative git repository paths as being relative to parent project's remote.
- CMP0149: Visual Studio generators select latest Windows SDK by default.
- CMP0148: The FindPythonInterp and FindPythonLibs modules are removed.
- CMP0147: Visual Studio generators build custom commands in parallel.
- CMP0146: The FindCUDA module is removed.
- CMP0145: The Dart and FindDart modules are removed.
- CMP0144: find_package uses upper-case PACKAGENAME_ROOT variables.
Policies Introduced by CMake 3.26¶
Policies Introduced by CMake 3.25¶
Policies Introduced by CMake 3.24¶
- CMP0139: The if() command supports path comparisons using PATH_EQUAL operator.
- CMP0138: CheckIPOSupported uses flags from calling project.
- CMP0137: try_compile() passes platform variables in project mode.
- CMP0136: Watcom runtime library flags are selected by an abstraction.
- CMP0135: ExternalProject and FetchContent ignore timestamps in archives by default for the URL download method.
- CMP0134: Fallback to "HOST" Windows registry view when "TARGET" view is not usable.
- CMP0133: The CPack module disables SLA by default in the CPack DragNDrop Generator.
- CMP0132: Do not set compiler environment variables on first run.
- CMP0131: LINK_LIBRARIES supports the LINK_ONLY generator expression.
- CMP0130: while() diagnoses condition evaluation errors.
Policies Introduced by CMake 3.23¶
Policies Introduced by CMake 3.22¶
Policies Introduced by CMake 3.21¶
- CMP0126: set(CACHE) does not remove a normal variable of the same name.
- CMP0125: find_(path|file|library|program) have consistent behavior for cache variables.
- CMP0124: foreach() loop variables are only available in the loop scope.
- CMP0123: ARMClang cpu/arch compile and link flags must be set explicitly.
- CMP0122: UseSWIG use standard library name conventions for csharp language.
- CMP0121: The list command detects invalid indices.
Policies Introduced by CMake 3.20¶
- CMP0120: The WriteCompilerDetectionHeader module is removed.
- CMP0119: LANGUAGE source file property explicitly compiles as language.
- CMP0118: GENERATED sources may be used across directories without manual marking.
- CMP0117: MSVC RTTI flag /GR is not added to CMAKE_CXX_FLAGS by default.
- CMP0116: Ninja generators transform DEPFILEs from add_custom_command().
- CMP0115: Source file extensions must be explicit.
Policies Introduced by CMake 3.19¶
- CMP0114: ExternalProject step targets fully adopt their steps.
- CMP0113: Makefile generators do not repeat custom commands from target dependencies.
- CMP0112: Target file component generator expressions do not add target dependencies.
- CMP0111: An imported target missing its location property fails during generation.
- CMP0110: add_test() supports arbitrary characters in test names.
- CMP0109: find_program() requires permission to execute but not to read.
Policies Introduced by CMake 3.18¶
- CMP0108: A target cannot link to itself through an alias.
- CMP0107: An ALIAS target cannot overwrite another target.
- CMP0106: The Documentation module is removed.
- CMP0105: Device link step uses the link options.
- CMP0104: CMAKE_CUDA_ARCHITECTURES now detected for NVCC, empty CUDA_ARCHITECTURES not allowed.
- CMP0103: Multiple export() with same FILE without APPEND is not allowed.
Policies Introduced by CMake 3.17¶
- CMP0102: mark_as_advanced() does nothing if a cache entry does not exist.
- CMP0101: target_compile_options honors BEFORE keyword in all scopes.
- CMP0100: Let AUTOMOC and AUTOUIC process .hh header files.
- CMP0099: Link properties are transitive over private dependencies of static libraries.
- CMP0098: FindFLEX runs flex in CMAKE_CURRENT_BINARY_DIR when executing.
Policies Introduced by CMake 3.16¶
Policies Introduced by CMake 3.15¶
- CMP0094: FindPython3, FindPython2 and FindPython use LOCATION for lookup strategy.
- CMP0093: FindBoost reports Boost_VERSION in x.y.z format.
- CMP0092: MSVC warning flags are not in CMAKE_{C,CXX}_FLAGS by default.
- CMP0091: MSVC runtime library flags are selected by an abstraction.
- CMP0090: export(PACKAGE) does not populate package registry by default.
- CMP0089: Compiler id for IBM Clang-based XL compilers is now XLClang.
Policies Introduced by CMake 3.14¶
- CMP0088: FindBISON runs bison in CMAKE_CURRENT_BINARY_DIR when executing.
- CMP0087: install(SCRIPT | CODE) supports generator expressions.
- CMP0086: UseSWIG honors SWIG_MODULE_NAME via -module flag.
- CMP0085: IN_LIST generator expression handles empty list items.
- CMP0084: The FindQt module does not exist for find_package().
- CMP0083: Add PIE options when linking executable.
- CMP0082: Install rules from add_subdirectory() are interleaved with those in caller.
Policies Introduced by CMake 3.13¶
- CMP0081: Relative paths not allowed in LINK_DIRECTORIES target property.
- CMP0080: BundleUtilities cannot be included at configure time.
- CMP0079: target_link_libraries allows use with targets in other directories.
- CMP0078: UseSWIG generates standard target names.
- CMP0077: option() honors normal variables.
- CMP0076: target_sources() command converts relative paths to absolute.
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)
or
cmake_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¶
- 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, 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¶
- 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, Removed by CMake 4.0¶
- 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, Removed by CMake 4.0¶
- 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.