feature: Use CCACHE if possible

This commit is contained in:
Fijxu 2024-03-13 08:16:00 +00:00 committed by Crimson Hawk
parent b09f9ee1f4
commit 84aa715eb1

View file

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