srb2: Simplify cmake patch

This commit is contained in:
Donovan Glover 2023-05-23 08:44:46 -04:00
parent 7170a915e6
commit 4b63d5b7e5
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65

View File

@ -1,35 +1,11 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 915912af5..9deb22a2a 100644
index 915912af5..f5c2cf9cc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -76,26 +76,16 @@ option(SRB2_CONFIG_ZDEBUG "Compile with ZDEBUG defined." OFF)
option(SRB2_CONFIG_PROFILEMODE "Compile for profiling (GCC only)." OFF)
set(SRB2_CONFIG_ASSET_DIRECTORY "" CACHE PATH "Path to directory that contains all asset files for the installer. If set, assets will be part of installation and cpack.")
-# Enable CCache
-# (Set USE_CCACHE=ON to use, CCACHE_OPTIONS for options)
-if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL Windows)
- option(USE_CCACHE "Enable ccache support" OFF)
-
- if(USE_CCACHE)
- find_program(CCACHE_TOOL_PATH ccache)
- if(CCACHE_TOOL_PATH)
- set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE)
- set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE)
- else()
- message(WARNING "USE_CCACHE was set but ccache is not found (set CCACHE_TOOL_PATH)")
- endif()
+# Enable CCache early
+set(SRB2_USE_CCACHE OFF CACHE BOOL "Use CCache")
+if (${SRB2_USE_CCACHE})
+ find_program(CCACHE_PROGRAM ccache)
+ if(CCACHE_PROGRAM)
+ message(STATUS "Found CCache: ${CCACHE_PROGRAM}")
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
+ else()
+ message(WARNING "You have specified to use CCACHE but it was not found. Object files will not be cached.")
@@ -91,11 +91,6 @@ if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL Windows)
endif()
-else()
endif()
else()
- CPMAddPackage(
- NAME Ccache.cmake
- GITHUB_REPOSITORY TheLartians/Ccache.cmake
@ -38,24 +14,6 @@ index 915912af5..9deb22a2a 100644
endif()
# Dependencies
diff --git a/cmake/launch-c.in b/cmake/launch-c.in
new file mode 100644
index 000000000..c60558232
--- /dev/null
+++ b/cmake/launch-c.in
@@ -0,0 +1,3 @@
+#!/bin/sh
+export CCACHE_CPP2=true
+exec "${RULE_LAUNCH_COMPILE}" "${CMAKE_C_COMPILER}" "$@"
diff --git a/cmake/launch-cxx.in b/cmake/launch-cxx.in
new file mode 100644
index 000000000..c60558232
--- /dev/null
+++ b/cmake/launch-cxx.in
@@ -0,0 +1,3 @@
+#!/bin/sh
+export CCACHE_CPP2=true
+exec "${RULE_LAUNCH_COMPILE}" "${CMAKE_C_COMPILER}" "$@"
--
2.40.1