CMake vs Ninja

In this article, we have explored the differences between CMake and Ninja which are important tools for the Build process. We have presented a summary table as well.

Table of contents:

  1. Background of CMake and Ninja
  2. CMake vs Ninja
  3. Summary Table
  4. Conclusion

CMake vs Ninja

Background of CMake and Ninja

From 1976, Make tool was the most prominent way to build Software Projects. It had some drawbacks:

  • Problem 1: For each system, the build files for Make had to be modified.
  • Problem 2: Make was slow for large projects (number of code files >= 10,000 like in Google Chrome)

The solution to the 1st problem came in 2000 with the introduction of CMake. CMake is a build generator which customizes Make build files automatically.

The solution to the 2nd problem came in 2012 with the introduction to Ninja. Ninja was much faster and the main improvement was in the case of incremental builds.

CMake vs Ninja

  • CMake is a build generator while Ninja is a build tool.
  • CMake can use any build tool like Make or Ninja while Ninja has to use CMake as its build generator which is compulsory.
  • CMake was developed in 2000 by Kitware. On the other hand, Ninja was developed by Google in 2012 that is 12 years after CMake.
  • CMake is a Turing complete programming language while Ninja is not meant to be programmed. Ninja build files should always be developed using Build Generators like CMake.

Summary Table

Following table summarize the differences between CMake and Ninja:

CMake vs Ninja
Differences between CMake and Ninja
Prepared by iq.OpenGenus.org
PointCMakeNinja
Developed in20002012
Developer?KitwareGoogle
What?Build generatorBuild tool
Dependency?Can use any
Build Tool
Compulsory to use
CMake

Conclusion

As a concluding note, if you are working on a small project but aim to be able to build it on any system, you should use CMake to prepare build files for any Build tool of your choice.

If you are working on a large project with over 10,000 code files, then you should use Ninja build tool with CMake.