2013-09-13 17:01:40 +00:00
|
|
|
Using ccache
|
2013-09-15 04:25:12 +00:00
|
|
|
============
|
2013-09-13 17:01:40 +00:00
|
|
|
|
|
|
|
[ccache](http://ccache.samba.org/manual.html) is available in many
|
|
|
|
systems, and can dramatically improve compilation times. In particular
|
|
|
|
if we are constantly switching between different branches.
|
|
|
|
|
|
|
|
On Ubuntu, we can install ccache by executing
|
|
|
|
|
2013-09-15 04:18:05 +00:00
|
|
|
sudo apt-get install ccache
|
2013-09-13 17:01:40 +00:00
|
|
|
|
2013-09-15 04:25:12 +00:00
|
|
|
Using ccache with g++
|
|
|
|
---------------------
|
|
|
|
|
2013-09-13 17:01:40 +00:00
|
|
|
Then, we can create a simple script that invokes ccache with our
|
|
|
|
favorite C++ 11 compiler. For example, we can create the script
|
|
|
|
`~/bin/ccache-g++` with the following content:
|
|
|
|
|
2013-09-15 04:18:05 +00:00
|
|
|
#!/bin/sh
|
|
|
|
ccache g++ "$@"
|
2013-09-13 17:01:40 +00:00
|
|
|
|
|
|
|
Then, we instruct cmake to use `ccache-g++` as our C++ compiler
|
|
|
|
|
2013-09-15 04:18:05 +00:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=Debug -D CMAKE_CXX_COMPILER=~/bin/ccache-g++ ../../src
|
2013-09-13 17:01:40 +00:00
|
|
|
|
|
|
|
We usually use Ninja instead of make. Thus, our cmake command
|
|
|
|
line is:
|
|
|
|
|
2013-09-15 04:18:05 +00:00
|
|
|
cmake -D CMAKE_BUILD_TYPE=Debug -D CMAKE_CXX_COMPILER=~/bin/ccache-g++ -G Ninja ../../src
|
2013-09-15 04:25:12 +00:00
|
|
|
|
|
|
|
Using ccache with clang++
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
To use ccache with clang++, create the script ``~/bin/ccache-clang++``
|
|
|
|
with the following content:
|
|
|
|
|
|
|
|
#!/bin/sh
|
|
|
|
ccache clang++ -Qunused-arguments -fcolor-diagnostics "$@"
|
|
|
|
|
2013-09-15 04:30:57 +00:00
|
|
|
- ``-Qunused-arguments`` option is used to suppress "clang: warning:
|
2013-09-15 04:25:12 +00:00
|
|
|
argument unused during compilation:" warning.
|
|
|
|
- ``-fcolor-diagnostics`` option is used to enable clang's colored
|
|
|
|
diagnostic messages.
|