Переглянути джерело

feature: Use CCACHE if possible

Fijxu 2 роки тому
батько
коміт
84aa715eb1
1 змінених файлів з 16 додано та 0 видалено
  1. 16 0
      CMakeLists.txt

+ 16 - 0
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()