From a71ad40ac3646b33c47bfd6b2f62478b82e0f25d Mon Sep 17 00:00:00 2001 From: Pierre Wendling <50808272+FtZPetruska@users.noreply.github.com> Date: Tue, 15 Nov 2022 13:04:22 -0500 Subject: [PATCH] CMake: Add option to use Ccache. --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d27141d1f..3103b01f4 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()