setup-sdl: Blend 'CMAKE_*' environment variables into the cache hash

From 4b2a6d0b11aacdc5a7082e26a1f348d115e0f06a Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sat, 12 Aug 2023 12:43:13 +0200
Subject: [PATCH] Blend 'CMAKE_*' environment variables into the cache hash

---
 packed/index.js | 12 ++++++++----
 src/main.ts     |  7 +++++--
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/packed/index.js b/packed/index.js
index bfaac0a..a22dba5 100644
--- a/packed/index.js
+++ b/packed/index.js
@@ -486,8 +486,6 @@ function calculate_state_hash(args) {
         "LDFLAGS",
         "LIB",
         "LIBPATH",
-        "CMAKE_PREFIX_PATH",
-        "CMAKE_TOOLCHAIN_FILE",
         "MSYSTEM",
         "PKG_CONFIG_PATH",
     ];
@@ -496,6 +494,12 @@ function calculate_state_hash(args) {
         var key = ENV_KEYS_1[_i];
         env_state.push("".concat(key, "=").concat(process.env[key]));
     }
+    for (var _a = 0, _b = Object.keys(process.env); _a < _b.length; _a++) {
+        var key = _b[_a];
+        if (key.startsWith("CMAKE_")) {
+            env_state.push("".concat(key, "=").concat(process.env[key]));
+        }
+    }
     var ACTION_KEYS = [
         "build-type",
         "cmake-toolchain-file",
@@ -504,8 +508,8 @@ function calculate_state_hash(args) {
         "sdl-test",
     ];
     var inputs_state = [];
-    for (var _a = 0, ACTION_KEYS_1 = ACTION_KEYS; _a < ACTION_KEYS_1.length; _a++) {
-        var key = ACTION_KEYS_1[_a];
+    for (var _c = 0, ACTION_KEYS_1 = ACTION_KEYS; _c < ACTION_KEYS_1.length; _c++) {
+        var key = ACTION_KEYS_1[_c];
         var v = core.getInput(key);
         inputs_state.push("".concat(key, "=").concat(v));
     }
diff --git a/src/main.ts b/src/main.ts
index c6da9c1..78501d2 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -212,8 +212,6 @@ function calculate_state_hash(args: {
     "LDFLAGS",
     "LIB",
     "LIBPATH",
-    "CMAKE_PREFIX_PATH",
-    "CMAKE_TOOLCHAIN_FILE",
     "MSYSTEM",
     "PKG_CONFIG_PATH",
   ];
@@ -221,6 +219,11 @@ function calculate_state_hash(args: {
   for (const key of ENV_KEYS) {
     env_state.push(`${key}=${process.env[key]}`);
   }
+  for (const key of Object.keys(process.env)) {
+    if (key.startsWith("CMAKE_")) {
+      env_state.push(`${key}=${process.env[key]}`);
+    }
+  }
 
   const ACTION_KEYS = [
     "build-type",