SDL: Fix Metal GPU backend not being included in CMake configuration

From e66f1b516255a1efe2b85634e1fcc7d5def965ff Mon Sep 17 00:00:00 2001
From: zn-arf <[EMAIL REDACTED]>
Date: Sun, 29 Mar 2026 17:01:48 +0200
Subject: [PATCH] Fix Metal GPU backend not being included in CMake
 configuration

Fixes #15285

Missing Metal GPU block in CMakeLists.txt prevents `HAVE_SDL_GPU` from being set when only Metal is enabled.
---
 CMakeLists.txt | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d8afc5d4a4c06..350d5c747e8c3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2735,13 +2735,6 @@ elseif(APPLE)
           set(SDL_VIDEO_RENDER_METAL 1)
           set(HAVE_RENDER_METAL TRUE)
         endif()
-        if (SDL_GPU)
-          set(SDL_GPU_METAL 1)
-          sdl_glob_sources(
-            "${SDL3_SOURCE_DIR}/src/gpu/metal/*.m"
-            "${SDL3_SOURCE_DIR}/src/gpu/metal/*.h"
-          )
-        endif()
       endif()
     endif()
   endif()
@@ -3554,6 +3547,14 @@ if(SDL_GPU)
     set(SDL_GPU_VULKAN 1)
     set(HAVE_SDL_GPU TRUE)
   endif()
+  if(SDL_VIDEO_METAL)
+    sdl_glob_sources(
+      "${SDL3_SOURCE_DIR}/src/gpu/metal/*.m"
+      "${SDL3_SOURCE_DIR}/src/gpu/metal/*.h"
+    )
+    set(SDL_GPU_METAL 1)
+    set(HAVE_SDL_GPU TRUE)
+  endif()
   if(SDL_RENDER_GPU AND HAVE_SDL_GPU)
     set(SDL_VIDEO_RENDER_GPU 1)
     set(HAVE_RENDER_GPU TRUE)