Using cmake with ninja build system

Recently IT++ has switched to a new build system based on cmake. cmake is a much flexible option for generating files needed for compilation. On Linux, for example, cmake generates by default Makefiles, but the latest cmake versions (e.g. 2.8.9) have the option to generate Ninja files instead. Ninja is a small build system designed for speed ( and can be seen as a replacement for make.

Here is the command used to generate Ninja files (assuming that you are in a folder just below the root source folder):
cmake .. -G Ninja -DCMAKE_MAKE_PROGRAM=/path/to/ninja

To compile use:

Here are the execution times obtained with both make and ninja:
- With ninja:
real 3m13.338s user 3m20.055s sys 0m37.187s
- With make:
real 4m0.985s user 3m15.387s sys 0m37.745s

On my machine ninja seems to be almost 1.3 times faster than make, however this depends on machine processing power. Differences even greater can be obtained if only the sources are compiled (in my tests both the sources and HTML documentation were compiled). Thus, ninja seems to be a good replacement for make, especially for developers who need to often recompile the source code.

Posted by Bogdan Cristea 2012-09-23 Labels: cmake ninja build systems