/changelogs/cmake/cmake-3-to-4
CMake 3 to 4: Compatibility with CMake < 3.5 has been removed
- tool
- CMake
- versions
- 3.x → 4.x
CMake keeps old behaviour through policies, which cmake_minimum_required(VERSION x) sets to their state at version x. CMake 4.0 removed the old behaviour of all policies introduced before 3.5, so any project, or vendored dependency, that declares a minimum below 3.5 stops at configure time. Many older libraries still have cmake_minimum_required(VERSION 2.8) or 3.1.
What CMake 4 does with old minimums
CMake 4.4 from the cmake Python wheel, three minimum versions:
cmake() { uv run -q --no-project --python 3.13 --with cmake==4.4.4 --with ninja cmake "$@"; }
cmake --version | head -1
for v in 3.0 3.5 3.10; do
printf 'cmake_minimum_required(VERSION %s)\nproject(demo LANGUAGES NONE)\n' "$v" > CMakeLists.txt
rm -rf build
echo "=== VERSION $v"
cmake -G Ninja -S . -B build 2>&1 | grep -E 'Error|Warning|Compatibility|Configuring|Generating done' ; echo "exit status: ${PIPESTATUS[0]}"
doneOutput
cmake version 4.4.4 === VERSION 3.0 CMake Error at CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 3.5 has been removed from CMake. -- Configuring incomplete, errors occurred! exit status: 1 === VERSION 3.5 CMake Warning (deprecated) at CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 3.10 will be removed from a future version of -- Configuring done (0.1s) -- Generating done (0.0s) exit status: 0 === VERSION 3.10 -- Configuring done (0.1s) -- Generating done (0.0s) exit status: 0
Fixes
# your own project: declare what you actually test with
cmake_minimum_required(VERSION 3.16...4.4)The min...max form says the project needs at least min and was updated for the policies up to max, so new CMake versions do not warn.
For a third-party project you cannot edit, configure anyway with a policy minimum:
cmake -S . -B build -DCMAKE_POLICY_VERSION_MINIMUM=3.5Or set the environment variable CMAKE_POLICY_VERSION_MINIMUM=3.5, which also reaches dependencies built through FetchContent or ExternalProject. Better still, update the dependency to a release that declares a newer minimum.