This adds an option (USE_CCACHE) to build using ccache if found. Makefiles, ninja and Xcode are supported. I'm afraid I have no knowledge of Windows development, so I don't know if this could be made to work with Visual Studio too.
This is all based on https://github.com/TheLartians/Ccache.cmake
Examples:
From the root of the blender source tree, run make BUILD_CMAKE_ARGS=-DUSE_CCACHE=YES ninja to build with ninja using ccache.
cmake . -DUSE_CCACHE=YES -B ../build_xcode -G "Xcode" will build an Xcode project which uses ccache.