CMake: Add option to use Ccache.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d27141d..3103b01 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -513,6 +513,7 @@ dep_option(SDL_HIDAPI_JOYSTICK "Use HIDAPI for low level joystick drivers" O
dep_option(SDL_VIRTUAL_JOYSTICK "Enable the virtual-joystick driver" ON SDL_HIDAPI OFF)
set_option(SDL_ASAN "Use AddressSanitizer to detect memory errors" OFF)
option_string(SDL_VENDOR_INFO "Vendor name and/or version to add to SDL_REVISION" "")
+set_option(SDL_CCACHE "Use Ccache to speed up build" ON)
option(SDL_WERROR "Enable -Werror" OFF)
@@ -3113,6 +3114,19 @@ if (SDL_ASAN)
endif()
endif()
+if(SDL_CCACHE)
+ cmake_minimum_required(VERSION 3.4)
+ find_program(CCACHE_BINARY ccache)
+ if(CCACHE_BINARY)
+ set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_BINARY})
+ set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_BINARY})
+ set(CMAKE_OBJC_COMPILER_LAUNCHER ${CCACHE_BINARY})
+ set(HAVE_CCACHE ON)
+ else()
+ set(HAVE_CCACHE OFF)
+ endif()
+endif()
+
if(SDL_TESTS)
set(HAVE_TESTS ON)
endif()