Skip to content

/errors/cmake/compatibility-with-cmake-3-5-removed

CMake Error: Compatibility with CMake < 3.5 has been removed from CMake.

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
tool
CMake
exit code
1
versions
CMake 4.x
os
linux, macos, windows

CMake 4.0 removed compatibility with versions older than 3.5, so cmake_minimum_required(VERSION X) with X below 3.5 is now a fatal error: Compatibility with CMake < 3.5 has been removed from CMake. Raise the version in cmake_minimum_required (3.10 or later avoids the follow-up deprecation warning). If the line is in a dependency you cannot change, configure with -DCMAKE_POLICY_VERSION_MINIMUM=3.5, as the message itself suggests.

Reproduce it

The block runs CMake 4.4 from the cmake PyPI package with the Ninja generator; project(demo NONE) needs no compiler:

bash
cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.0)
project(demo NONE)
message(STATUS "configured with CMake ${CMAKE_VERSION}")
EOF
uv run -q --no-project --python 3.13 --with cmake==4.4.4 --with ninja==1.13.0 cmake -S . -B build -G Ninja

Output · exit 1

CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 has been removed from CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.

  Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.

-- Configuring incomplete, errors occurred!

Fix your own project

bash
cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.5...3.31)
project(demo NONE)
message(STATUS "configured with CMake ${CMAKE_VERSION}")
EOF
uv run -q --no-project --python 3.13 --with cmake==4.4.4 --with ninja==1.13.0 cmake -S . -B build -G Ninja | grep -vE 'Configuring done|Generating done|Build files'

Output

-- configured with CMake 4.4.4

VERSION 3.5...3.31 means "requires at least 3.5, and behaves like 3.31 when available": older CMake 3 releases still accept the file, while CMake 4 sets every policy up to 3.31 to NEW. A plain VERSION 3.5 would also configure, but prints a deprecation warning because compatibility with versions below 3.10 is scheduled for removal next.

Third-party code: CMAKE_POLICY_VERSION_MINIMUM

bash
cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.0)
project(demo NONE)
message(STATUS "configured with CMake ${CMAKE_VERSION}")
EOF
uv run -q --no-project --python 3.13 --with cmake==4.4.4 --with ninja==1.13.0 cmake -S . -B build -G Ninja -DCMAKE_POLICY_VERSION_MINIMUM=3.5 2>&1 | grep -vE 'Configuring done|Generating done|Build files'

Output

CMake Warning (deprecated) at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
This warning is for project developers.  Use -Wno-author or -Wno-deprecated
to suppress it.

-- configured with CMake 4.4.4

CMAKE_POLICY_VERSION_MINIMUM (CMake 4.0 and later) raises the effective minimum of every cmake_minimum_required call, including those in subprojects. It can also be set as an environment variable, which helps when CMake is called by another tool (pip, cargo, vcpkg, conan):

bash
export CMAKE_POLICY_VERSION_MINIMUM=3.5
pip install some-package-with-cmake-build

Find out where the old version comes from

The first line of the error names the file and line: CMake Error at CMakeLists.txt:1 (cmake_minimum_required) is your own top-level file, while a path such as build/_deps/somelib-src/CMakeLists.txt or third_party/somelib/CMakeLists.txt points to a dependency. To list every declaration in a source tree at once:

bash
grep -rn --include=CMakeLists.txt --include='*.cmake' -iE 'cmake_(minimum_required|policy)\s*\(\s*VERSION' .

Any version below 3.5 in that list fails on CMake 4; versions from 3.5 up to 3.9 configure but print the deprecation warning shown above. Run cmake --version to confirm which CMake is actually running: a Python virtual environment, a CI image or a package manager can put a newer cmake first on PATH than the one you installed.

Which fix to choose

SituationFixHow to confirm
Your own CMakeLists.txtcmake_minimum_required(VERSION 3.10...4.4) or the range you test withconfigure prints no error and no deprecation warning
Dependency with a newer releaseupdate the version in FetchContent, the submodule or the package managerthe path in the error disappears on the next configure
Dependency you cannot change yet-DCMAKE_POLICY_VERSION_MINIMUM=3.5 or the environment variablethe error turns into the deprecation warning and configure completes
Old project you only need to build oncerun it with a CMake 3.x releasecmake --version shows 3.x and configure completes

After changing the minimum, delete the build directory or configure with --fresh, so no cached state from the failed run is reused. See CMake 3 to 4 for the other changes in CMake 4.0.

Prevention

Declare a range (min...max) rather than a single version, and raise max when you test a new CMake release. Pin the CMake version in CI (for example cmake==4.4.4 from PyPI, as in the blocks above) and upgrade it deliberately, so a new major release cannot break the build without a code change. When you vendor or fetch a library, check its cmake_minimum_required line as part of the review.

FAQ

Which CMake versions show this error?

CMake 4.0 and every later release. CMake 3.x only warns about old minimum versions, so the same project may configure fine on a machine that still has CMake 3.

How do I find which CMakeLists.txt has the old version?

Read the path in the first line of the error, CMake Error at PATH:LINE. A path under _deps or a third-party folder means the problem is in a dependency, not your own file.

Is cmake_policy(VERSION 2.8) also affected?

Yes. The CMake 4.0 release notes say that calls to cmake_minimum_required() or cmake_policy() that set the policy version below 3.5 now issue an error.

Sources