CMake policies vs. minimum CMake version
Most CMake policies default to “OLD” behavior compatible with prior versions of CMake. cmake_minimum_required(VERSION min…max) automatically sets all the CMake policies to “new” through the “max” CMake version, limited by the user’s CMake version.
Example: project with cmake_minimum_required(VERSION 3.21...3.26)
implicitly sets to NEW
all CMake policies CMP0143 and older for users with CMake ≥ 3.26.
A user with CMake 3.22 will get NEW for policies CMP0128 and older.
A user with CMake 3.20 will get an error due to the minimum version given as 3.21.
New versions of CMake don’t get the benefits of new behaviors until specifying the new behavior is OK via cmake_minimum_required(VERSION min...max)
maximum version number.
CMake gradually deprecates old policies, such that warnings emit when CMakeLists.txt cmake_policy()
or cmake_minimum_required()
sets the policy to OLD.
For example, CMake 3.28
deprecated CMake 3.20 CMP0120
and older.