typically default to
OLD behavior compatible with prior versions of CMake.
automatically sets all the CMake policies to “new” through the minimum CMake version.
For example, a project with
cmake_minimum_required(VERSION 3.14) implicitly sets to
NEW all CMake policies CMP0088 and older.
New versions of CMake don’t get the benefits of new behaviors until specifying the new behavior is OK, either implicitly via
cmake_minimum_required() or explicitly via
The downsides of a too-old
cmake_minimum_required() include that you have to set
if(CMAKE_VERSION VERSION_GREATER_EQUAL ...) statements around extra
Here are a few CMake policies we generally use, typically implicitly by choosing at least CMake 3.13:
- CMP0074 find_package uses PackageName_ROOT variables
- CMP0076 target_sources() command converts relative paths to absolute. This allows specifying targets in the top-level CMakeLists.txt while having
add_subdirectory()containing their sources.
- CMP0077 option() honors normal variables. Does not manipulate variables when user has defined their value.
CMake gradually deprecates old policies, meaning the deprecated policies default to
For example, CMake 3.18 deprecates CMP0071 and older.