Using ninja

Some tips regarding using Ninja.

Basic using

Assuming the Ninja build system is installed properly, previously, we may use cmake -B <install dir> -S <src dir> ... to set the cmake configurations and then using cmake --build <install dir> -j<job_number> to do the install.

If we want to build the project based on cmake and Ninja, we just need to use make -B <install dir> -S <src dir> -GNinja after executing the cmake, we can continue to use the cmake --build to build the project based on Ninja. The Ninja version will save a lot of output and make the building process clean.

Getting tracing file

One benifit of using Ninja is to get the time trace for each object file, this is really good way to solve the issue regarding the compiling time.

This is one example to show how Ninja can help to solve particular problem.

The ninjatracing is a really good tool to transfer the ninja output to the gantt chart that can be analysied by some visualization tool, such as this one direactly. This is a good workflow to do the tracing, we just need to transfer the tracing log into the specific json format and analysi it direactly. We do not need to write the visualization tool from scratch.

推荐文章