cmake config_error ai_generated true

CMake Error: Could not create named generator 'Ninja' because the generator requires CMake >= 3.20 but you are running version 3.18.4

ID: cmake/ninja-requires-cmake-3-20

Also available as: JSON · Markdown · 中文
88%Fix Rate
85%Confidence
1Evidence
2023-08-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
CMake 3.18.4 active
CMake 3.20.0 active
Ninja 1.11.0 active

Root Cause

The Ninja generator (or a specific Ninja version) requires a newer CMake, but an older CMake is installed.

generic

中文

Ninja生成器(或特定Ninja版本)需要更新的CMake,但安装了较旧的CMake。

Official Documentation

https://cmake.org/cmake/help/latest/generator/Ninja.html

Workarounds

  1. 90% success Upgrade CMake to version 3.20 or later. On Ubuntu: sudo apt install cmake=3.20.0-* or download from cmake.org.
    Upgrade CMake to version 3.20 or later. On Ubuntu: sudo apt install cmake=3.20.0-* or download from cmake.org.
  2. 80% success Use an alternative generator like 'Unix Makefiles' if Ninja is not strictly needed: cmake -G "Unix Makefiles" ..
    Use an alternative generator like 'Unix Makefiles' if Ninja is not strictly needed: cmake -G "Unix Makefiles" ..

中文步骤

  1. 升级CMake至3.20或更高版本。在Ubuntu上:sudo apt install cmake=3.20.0-* 或从cmake.org下载。
  2. 如果不需要Ninja,使用替代生成器如'Unix Makefiles':cmake -G "Unix Makefiles" ..

Dead Ends

Common approaches that don't work:

  1. 85% fail

    CMake explicitly checks version requirements and refuses to use incompatible generators.

  2. 65% fail

    The version requirement is intrinsic to the generator's features, not Ninja itself; downgrading Ninja may break other builds.