CMakeLists: Use ccache if found
Dramatically speeds up builds when switching build flags.
Change-Id: I661d18458db69f6663381c252b06b3ed96f3a5c6
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/33472
Tested-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7cc7713..23d9310 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -62,6 +62,14 @@
"host compiler, pass -Thost=x64 on the CMake command line.")
endif()
+# Use CCache if available
+find_program(CCACHE_FOUND ccache)
+if(CCACHE_FOUND)
+ message(STATUS "Using ccache")
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
+endif(CCACHE_FOUND)
+
###########################################################
# Options
###########################################################