Using Ninja and ccache to build OTB faster

From OTBWiki
Revision as of 09:25, 9 June 2016 by Julien (Talk | contribs) (Created page with "These are tips to build OTB faster if you need to rebuild it often. Those tips are independent: you can use one or the other, or both. === Using Ninja === Recent versions of...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

These are tips to build OTB faster if you need to rebuild it often. Those tips are independent: you can use one or the other, or both.

Using Ninja

Recent versions of cmake supports Ninja, an alternative build system that is supposedly faster than make. The only thing to do is to install *ninja* with your favorite package manager, and then use the following for cmake configuration :

$ cmake -G Ninja path_to_otb_sources/

You can replace cmake by ccmake if you want to enter the interactive cmake configuration.

Now you can build by running

$ ninja

instead of

$ make

Please note that you need to start configuration from scratch: you can not switch CMake generator after the initial configuration.

Also note that ninja will use a lot of threads by default, so you may want to limit this with:

$ ninja -j 2

Using ccache

Ccache is a caching system that allows to avoid recompiling things that you already compiled once. You need to install ccache with your favorite package manager, and then use the following for cmake configuration:

$ CC=/usr/lib/ccache/cc CXX=/usr/lib/ccache/c++ cmake path_to_otb_sources/

And that is all. First build will populate the cache, and subsequent build will be faster.