CMake: Add option to use Ccache.

This commit is contained in:
Pierre Wendling 2022-11-15 13:04:22 -05:00 committed by GitHub
parent 5e61f245ab
commit a71ad40ac3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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()