Using Ninja and ccache to build OTB faster
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.
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
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
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.