build: Add optional ccache support to cmake
authorCody Northrop <cnorthrop@google.com>
Tue, 31 Oct 2017 23:05:03 +0000 (17:05 -0600)
committerCody Northrop <cnorthrop@google.com>
Fri, 3 Nov 2017 22:03:59 +0000 (16:03 -0600)
BUILD.md
CMakeLists.txt

index bb78c9c..8b884c9 100644 (file)
--- a/BUILD.md
+++ b/BUILD.md
@@ -40,6 +40,8 @@ cd dbuild
 make
 ```
 
+If your build system supports ccache, you can enable that via cmake option `-DUSE_CCACHE=On`
+
 If you have installed a Vulkan driver obtained from your graphics hardware vendor, the install process should
 have configured the driver so that the Vulkan loader can find and load it.
 
index 2412236..8b91674 100644 (file)
@@ -15,6 +15,15 @@ string(TOLOWER ${API_NAME} API_LOWERCASE)
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
 find_package(PythonInterp 3 REQUIRED)
 
+option(USE_CCACHE "Use ccache" OFF)
+if (USE_CCACHE)
+    find_program(CCACHE_FOUND ccache)
+    if(CCACHE_FOUND)
+        set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
+        set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
+    endif(CCACHE_FOUND)
+endif()
+
 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
     set(FALLBACK_CONFIG_DIRS "/etc/xdg" CACHE STRING
         "Search path to use when XDG_CONFIG_DIRS is unset or empty or the current process is SUID/SGID. Default is freedesktop compliant.")