cmake: Enable ccache by default, if available
Check for the existence of the ccache binary, and enable ccache
support if available. This avoids the need for hacks using PATH
or the CXX variable to make ccache work.
The automatic detection can be disabled by passing -DUSE_CCACHE=OFF
to CMake (may be useful for distributors having their own ccache
infrastructure in place).
Reorder things in the top-level CMakeLists.txt a bit, because ccache
should be enabled before calling project() (which checks compiler
settings).