This patch has the following changes
The CMake variable LLVM_CCACHE_BUILD is set to OFF by default.
Set this to ON for a ccache enabled build
CCACHE_CPP2 is required to compile the source file directly instead
of compiling the preprocessed file. This will help WERROR is turned ON
for a host clang compiler
The below two options makes more sense in the context of a buildbot
CCACHE_HASHDIR is required to maintain the separate cached data across
builders. This will also help the debuggers to point to the correct source
location
CCACHE_SIZE is important in the perspective of buildbot to increase the
limit on the amount of data to hold in cache for faster compilation
CCACHE_DIR is used to save the cached data to a specific directory.
I think the CMAKE_SYSTEM_NAME check here is unnecessary. ccache works on FreeBSD, OS X, and probably under MingW32, so I suspect if the program is present it should just be used.
I'm not sure how ccache behaves on Windows, so you might need to ensure that if you're on windows you're also on MingW32, which would be something like:
I also think it would be good to log an error if LLVM_CCACHE_BUILD=On and CCACHE_PROGRAM is not found.