SDL: cmake: SDL2 target is not always available (b7457)

From b7457ff61b0b520b9d94ef77fe6a410a6c8141f4 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sun, 4 Aug 2024 15:52:16 +0200
Subject: [PATCH] cmake: SDL2 target is not always available

(cherry picked from commit 7cf3234efeb7a68636bcfdfb3b1507b43fbb0845)
---
 CMakeLists.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 284c2a6f567a3..a214d734e2c03 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3520,7 +3520,10 @@ if(SDL_TEST)
 endif()
 
 if(MSVC AND NOT SDL_LIBC)
-  set(targets SDL2)
+  set(targets )
+  if(TARGET SDL2)
+    list(APPEND targets SDL2)
+  endif()
   if(TARGET SDL2-static)
     list(APPEND targets SDL2-static)
   endif()