CMake "version X or higher is required" (cmake_minimum_required) in CI
The project declares a minimum CMake version via cmake_minimum_required, and the CMake on the runner is older than that. CMake refuses to configure until you install a newer version.
What this error means
cmake fails on the first line of CMakeLists.txt with "CMake 3.25 or higher is required. You are running 3.22.1", because the runner image ships an older CMake.
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
CMake 3.25 or higher is required. You are running version 3.22.1Common causes
The runner image ships an older CMake
Distro packages lag behind, so the pre-installed cmake is older than what the project requires.
A dependency raised the minimum
A newly added dependency or preset bumped cmake_minimum_required beyond the CMake already on the runner.
How to fix it
Install a newer CMake in CI
Use an action that provisions a recent CMake instead of the distro package.
- uses: lukka/get-cmake@latest
with:
cmakeVersion: '3.28.3'Install from Kitware's apt repository
On Ubuntu runners, add Kitware's repo to get a current cmake.
sudo apt-get update && sudo apt-get install -y cmake
cmake --versionHow to prevent it
- Pin the CMake version in CI to at least the project minimum.
- Do not rely on the distro-provided cmake for modern projects.
- Bump the CI CMake when cmake_minimum_required rises.