[CMake] CMake + Ninja

Clifford Yapp cliffyapp at gmail.com
Fri Jan 6 09:11:23 EST 2012


Peter Collingbourne's ongoing work with CMake support for ninja (and
vice versa) was recently announced as being able to build multiple
large projects:

http://public.kitware.com/pipermail/cmake-developers/2011-November/002490.html

BRL-CAD was on the list, and in trials last night I confirmed that it
does indeed build BRL-CAD - nice work Peter!

The no-op build was indeed extremely fast (less than a second, vs.
more than ten even with a parallel make), and the full build time was
8 minutes 43 seconds as opposed to 9 minutes 8 seconds for make
(considering this is a Gentoo box and my compilation toolchains tend
to be optimized, I was actually pretty impressed - I will be
especially curious to see what happens on a Mac.  It would be
interesting to figure out a way to identify the "compiler time only"
number and be able to characterize the actual make/ninja overhead, to
know how close ninja comes to the ultimate least-time-possible build.)

In case anybody else wants to give ninja a spin, here's what I did to
test it (using bash as a shell):

git clone git://github.com/martine/ninja.git
git clone -b ninja-generator-pr git://github.com/pcc/CMake.git
export PATH=/home/user/ninja:/home/user/cmake-install:$PATH
cd ninja
./bootstrap.py
cd ../CMake
./bootstrap --prefix=/home/user/cmake-install
gmake && gmake install

Then configure your projects as normal, but specify the Ninja generator:

cmake -G Ninja

and build with ninja instead of make:

ninja


You can also specify individual targets - for example, if I want to
build just the main editor of BRL-CAD I can do:

ninja mged


More information about the CMake mailing list