cmake
config_error
ai_generated
true
CMake Error: Could not create named generator 'Ninja'. Generator 'Ninja' is not available. Use 'cmake --help' to see a list of available generators.
ID: cmake/generator-ninja-not-found
95%Fix Rate
90%Confidence
1Evidence
2023-07-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.14 | active | — | — | — |
| 3.20 | active | — | — | — |
| 3.24 | active | — | — | — |
| 3.27 | active | — | — | — |
Root Cause
CMake was invoked with -GNinja but Ninja is not installed or not in PATH, or the CMake installation does not include the Ninja generator (e.g., minimal install).
generic中文
CMake 使用 -GNinja 调用,但 Ninja 未安装或不在 PATH 中,或者 CMake 安装不包含 Ninja 生成器(例如,最小安装)。
Official Documentation
https://cmake.org/cmake/help/latest/manual/cmake-generators.7.htmlWorkarounds
-
95% success Install Ninja: on Ubuntu, run 'sudo apt-get install ninja-build'; on macOS, 'brew install ninja'; on Windows, download from https://ninja-build.org/ and add to PATH.
Install Ninja: on Ubuntu, run 'sudo apt-get install ninja-build'; on macOS, 'brew install ninja'; on Windows, download from https://ninja-build.org/ and add to PATH.
-
90% success Use a different generator such as Unix Makefiles: cmake -G "Unix Makefiles" ..
Use a different generator such as Unix Makefiles: cmake -G "Unix Makefiles" ..
-
85% success If Ninja is installed but not in PATH, specify the full path: cmake -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/local/bin/ninja ..
If Ninja is installed but not in PATH, specify the full path: cmake -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/local/bin/ninja ..
中文步骤
安装 Ninja:在 Ubuntu 上运行 'sudo apt-get install ninja-build';在 macOS 上运行 'brew install ninja';在 Windows 上从 https://ninja-build.org/ 下载并添加到 PATH。
使用其他生成器,例如 Unix Makefiles:cmake -G "Unix Makefiles" ..
如果 Ninja 已安装但不在 PATH 中,请指定完整路径:cmake -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/local/bin/ninja ..
Dead Ends
Common approaches that don't work:
-
Reinstalling CMake without selecting the Ninja generator option
90% fail
The Ninja generator is part of CMake's built-in generators; a reinstall without ensuring Ninja is in PATH does not help.
-
Setting CMAKE_GENERATOR to Ninja in CMakeLists.txt
95% fail
The generator is selected before CMakeLists.txt is parsed, so this setting has no effect; the error occurs at the configuration stage.
-
Using -G "Ninja Multi-Config" as a substitute
85% fail
If Ninja is not installed, the multi-config generator also fails because it requires the same underlying build tool.