# Fix "Compatibility with CMake < 3.5 Has Been Removed from CMake" After a CMake 4 Upgrade

Yes. An agent reproduces the configure error with CMake 4, raises cmake_minimum_required past the deprecated range, builds and runs the tests, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/fix-compatibility-with-cmake-3-5-has-been-removed/cmake/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent clones the repository into its own cloud sandbox and reads the build before changing it. In a header-only C++ library like aozturk/HashMap, `CMakeLists.txt` opens with `cmake_minimum_required(VERSION 2.8)` at line 1, then `project(hashmap CXX)`, a default `Profile` build type with `--coverage` flags, a long `-W` list ending in `-Werror`, and three options: `TESTING` (on, adds `test/`), `FORMAT` (on, defines targets that `wget` an astyle 2.05.1 tarball and build it) and `COV_HTML`. `test/CMakeLists.txt` builds two executables, `simple` and `complex`, and registers each with `add_test`. CI is `.github/workflows/cmake-multi-platform.yml`: `ubuntu-latest` with gcc and clang and `windows-latest` with cl, each running configure, `cmake --build` and `ctest` with whatever CMake the runner image carries.

Then it reproduces the failure. With CMake 4, `cmake -S . -B build` stops at once: `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.` followed by `Configuring incomplete, errors occurred!`. Nothing after line 1 runs, so the compiler is never even detected.

The obvious edit is not enough. Raising the line to `VERSION 3.5` configures, but CMake 4 prints `CMake Warning (deprecated) at CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 3.10 will be removed from a future version of CMake.`, which is the same message one release earlier. The agent sets `cmake_minimum_required(VERSION 3.10)` instead, which configures silently through `Configuring done` and `Generating done`. It passes `-DFORMAT=OFF` for the sandbox run, because the format targets download astyle from SourceForge, and says so.

It then builds and tests on the new minimum. `cmake --build` compiles `test/simple.cpp` and `test/complex.cpp` under the repository's own `-Werror` flag list, and `ctest` reports `test_simple` and `test_complex` passed. The agent checks the rest of the file for commands or policies a 3.10 minimum changes and finds none it relies on: `file(GLOB_RECURSE)`, `add_custom_target`, `install(DIRECTORY)` and the CPack variables all behave the same. The legacy `.travis.yml`, which ran the same configure, is left as it is and mentioned.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "CI fails at configure with \"Compatibility with CMake < 3.5 has been removed from CMake\". Read CMakeLists.txt, every CMakeLists.txt under it and the CI workflow first. Reproduce the error with the current CMake release and quote it. Raise cmake_minimum_required to the lowest version that configures without a deprecation warning on current CMake, explain why that version and not 3.5, and check the rest of the file for anything the new policy version changes. Configure, build and run ctest with the repository's own flags and quote the results. Do not add CMAKE_POLICY_VERSION_MINIMUM as a workaround. Open a pull request that quotes the failing and passing runs.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request that changes one line of `CMakeLists.txt`, `cmake_minimum_required(VERSION 2.8)` to `cmake_minimum_required(VERSION 3.10)`, and nothing else in the build. The description quotes the CMake 4 error at line 1, the deprecation warning that `VERSION 3.5` still produces, the silent configure at 3.10 with the compiler it found, and the `ctest` summary with both tests passing.

A reviewer checks that 3.10 is not newer than the CMake on the oldest machine they still build on, reads the one paragraph on policies the new minimum enables, and confirms the workaround flag was not added to CI. The run's record holds every configure, build and test command with its full output, so the before and after can be opened rather than taken on trust.

## Run it on every failed CI build

Add an automation to the Project with this prompt and a `webhook` trigger. A handler on your server that receives GitHub's `workflow_run` event for the build job calls the trigger's URL with the `Authorization: Bearer` header the trigger needs, and one run starts per failure with the payload after the prompt. Give the trigger's URL an `Idempotency-Key` made from the workflow run id, so a redelivered event starts nothing twice.

The same prompt fits a `schedule` trigger each Monday in your `timezone`, which catches the runner image's next CMake bump before it reaches a pull request; a week where configure is clean opens nothing.

## Why run it on Rush?

This failure arrives from outside the repository: nobody changed `CMakeLists.txt`, the runner's CMake moved to 4 and line 1 stopped being accepted. The agent reproduces it with the current release in its sandbox, so the pull request shows the exact error and the exact configure, build and test that proved the new minimum, and every command with its output stays in the run's record.

The one-line fix has a wrong answer that looks right: 3.5 makes the error go away and leaves the next deprecation warning in place. Because the agent runs configure on each candidate and reads the output, the pull request lands on 3.10 with the warning text that rules 3.5 out, instead of a change that will be back in a release or two.

## Frequently asked questions

### Why 3.10 and not 3.5?

CMake 4 accepts `VERSION 3.5` but warns that compatibility with versions below 3.10 will be removed next. Setting 3.10 configures with no warning today and does not need touching again at the next release. If a machine you build on still has a CMake older than 3.10, the pull request says so is the moment to pick a lower value and accept the warning.

### What about -DCMAKE_POLICY_VERSION_MINIMUM=3.5?

It is the escape hatch CMake prints for projects you cannot edit, such as a vendored dependency. For your own `CMakeLists.txt` it hides the problem in a CI flag; the prompt forbids it, and the agent changes the file instead.

### Does raising the minimum change how the project builds?

It enables the policies introduced up to that version. The agent reads the file for commands whose behavior those policies change and reports what it found; in this library there were none, and the build and tests ran the same under the repository's `-Werror` flags.

### Will it fix the min...max form instead?

`cmake_minimum_required(VERSION 3.10...4.0)` is the other form the error message suggests, and the agent uses it when a project wants newer policies on newer CMake. For a minimum only, the single value is clearer; the pull request names the alternative.

## More CMake jobs

- [Review Pull Requests on a CMake C++ Library](https://getrush.ai/run/review-pull-requests/cmake/)
- [Update GitHub Actions in a CMake Project's CI](https://getrush.ai/run/update-github-actions/cmake/)
- [Add ccache to a CMake Project's GitHub Actions Builds](https://getrush.ai/run/add-ccache-to-ci/cmake/)

## More jobs like this: Fix a bug from an alert

- [Fix "the attribute `version` is obsolete" in a Docker Compose File](https://getrush.ai/run/fix-compose-version-obsolete-warning/docker-compose/)
- [Fix "Configuration via mocha.opts is DEPRECATED" and the --opts error on Mocha 8 and later](https://getrush.ai/run/fix-configuration-via-mocha-opts-is-deprecated/mocha/)
- [Fix "Copy Plugin has been initialized using an options object that does not match the API schema"](https://getrush.ai/run/fix-copy-plugin-options-does-not-match-the-api-schema/copy-webpack-plugin/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
