Switch CMake Generator to Ninja

The default CMake build generator is operating system dependent. In general many projects can benefit from increased build speed and especially rebuild speed of Ninja. Switch the default build generator on any platform by setting environment variable CMAKE_GENERATOR.

CMAKE_GENERATOR=Ninja

Ninja executable can be downloaded and installed by any one of:

  • WinGet: winget install Ninja-build.Ninja
  • Python: pip install ninja
  • Homebrew: brew install ninja
  • Alpine Linux: apk add ninja-build

Optionally, add the location of the Ninja executable to environment variable CMAKE_PROGRAM_PATH to help CMake find Ninja.


Note that Ninja work-alikes like Samurai “samu” might get installed by default by some package managers. These work-alikes might not have a new-enough Ninja API equivalent, so in those cases install the actual Ninja program.


If using Conan Package Manager, tell Conan to use Ninja by setting environment variable

CONAN_CMAKE_GENERATOR=Ninja