From 84aa715eb1a0f99c8c2a6aa74485a6bb551666ef Mon Sep 17 00:00:00 2001 From: Fijxu Date: Wed, 13 Mar 2024 08:16:00 +0000 Subject: [PATCH] feature: Use CCACHE if possible --- CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9aeea1c13b..5a3f5f97d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,8 @@ CMAKE_DEPENDENT_OPTION(SUYU_USE_FASTER_LD "Check if a faster linker is available CMAKE_DEPENDENT_OPTION(USE_SYSTEM_MOLTENVK "Use the system MoltenVK lib (instead of the bundled one)" OFF "APPLE" OFF) +option(USE_CCACHE "Use CCache for faster building" ON) + set(DEFAULT_ENABLE_OPENSSL ON) if (ANDROID OR WIN32 OR APPLE) # - Windows defaults to the Schannel backend. @@ -733,3 +735,17 @@ if(ENABLE_QT AND UNIX AND NOT APPLE) install(FILES "dist/org.suyu_emu.suyu.metainfo.xml" DESTINATION "share/metainfo") endif() + +# Enable CCACHE. Linux only for now. +if (USE_CCACHE) + find_program(CCACHE_PROGRAM ccache) + if(CCACHE_PROGRAM) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") + if (SUYU_USE_PRECOMPILED_HEADERS) + message(NOTICE "To make use of CCache, set SUYU_USE_PRECOMPILED_HEADERS to OFF or else, it will barely be functional") + endif() + message(STATUS "CCache found.") + else() + message(STATUS "CCache has not been found and it will not be used. Install CCache or set USE_CCACHE to OFF") + endif() +endif()