I had noticed Ninja as one of the possible CMake generators long time ago, but never paid attention to it, as I could not imagine it being better than Make so much that it'd be worth switching. Then, when I posted my MySQL -ftime-trace results, I got a comment on LinkedIn that Ninja visualizes build time nicely. I tried that, and it did, and I went back to Make builds.
A few months later, I am looking at Vittorio Romeo's "Improving Compilation Times" presentation slides (download them, do not read inline on GitHub; there is also the talk video itself), and the very first low-hanging fruit advice is "use Ninja".
OK, so let's actually try, say, Debug build on Facebook MySQL 8.0.28:
make -j13: 4m43s
A 10% improvement with roughly zero effort is nice. There are other niceties too: you
don't have to figure out the right make parallelism argument for
-j, as Ninja
handles that automatically, and the terminal is not spammed with the build log of all
the source files that have been built uneventfully. Only compiler warnings and any
irregular build output is there.
To use it, add
-G Ninja to CMake invocation, and then use
ninja instead of
to build. I have patched my scripts.