The error indicates that CMake is configured to use the Ninja build system but cannot locate the ninja executable. Here's how to resolve it:
Step-by-Step Solution
1. Install Ninja
Ensure Ninja is installed on your system:
-
Linux (Ubuntu/Debian):
sudo apt update
sudo apt install ninja-build
-
macOS (Homebrew):
brew install ninja
-
Windows (via vcpkg):
vcpkg install ninja
Or download the pre-built ninja.exe from the official Ninja GitHub release page and add it to your system PATH.
-
Verify Installation:
ninja --version # Should output something like "v1.11.1"
2. Use a Different Build Tool (Optional)
If you don't specifically need Ninja, switch to a generator that matches your system:
-
Linux/macOS:
Use Unix Makefiles:
cmake -G "Unix Makefiles" ..
-
Windows:
Use Visual Studio or MinGW Makefiles:
cmake -G "Visual Studio 17 2022" ..
# or
cmake -G "MinGW Makefiles" ..
3. Set CMAKE_MAKE_PROGRAM Manually
If Ninja is installed but not in your PATH, specify its location explicitly:
cmake -DCMAKE_MAKE_PROGRAM=/path/to/ninja ..
Example:
cmake -DCMAKE_MAKE_PROGRAM=/usr/local/bin/ninja ..
4. Clear CMake Cache
If previously configured with Ninja, delete the cache and rebuild:
rm -rf CMakeCache.txt CMakeFiles
cmake ..
5. Verify Environment Variables
Ensure the directory containing ninja is in your system PATH:
Common Generators
To list all available generators:
cmake --help
Example output:
Generators
Unix Makefiles = Generates standard UNIX makefiles.
Ninja = Generates build.ninja files.
Visual Studio 17 2022 = Generates Visual Studio 2022 project files.
...
Summary
- Install Ninja if you want to use it.
- Or switch to a different generator (e.g.,
Unix Makefiles).
- Ensure
ninja is in your system PATH.
- Clear stale CMake configurations if needed.
Let me know if you need further help! 🛠️