Compile with Compiler Cache (ccache) if it's installed

Install with `sudo apt install ccache`.

Makes building a huge lot faster, especially when switching branches.
Nothing happens if ccache is not installed.

Example: (measured on my laptop)

```
$ ccache -C # clear the cache
$ rm -fr build
$ cd build
$ cmake -DWITH_XC_ALL=ON -DCMAKE_BUILD_TYPE=Release ..
$ time make -j4
...
real	5m8,817s
user	16m47,107s
sys	1m38,808s

$ rm -fr ../build/*
$ cmake -DWITH_XC_ALL=ON -DCMAKE_BUILD_TYPE=Release ..
$ time make -j4
...
real	0m32,571s
user	1m0,253s
sys	0m24,069s
```
This commit is contained in:
Wolfram Rösler 2019-06-09 22:10:58 +02:00 committed by Jonathan White
parent 54eafc8ebe
commit b13454eeb4

View File

@ -27,6 +27,13 @@ string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Use the Compiler Cache (ccache) if it is installed
# (install with: sudo apt get ccache)
find_program (CCACHE_FOUND ccache)
if (CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
endif (CCACHE_FOUND)
# Support Visual Studio Code
include(CMakeToolsHelpers OPTIONAL)