SDL: cmake: SDL2 target is not always available

From 7cf3234efeb7a68636bcfdfb3b1507b43fbb0845 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

---
 CMakeLists.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b025679239d06..a30a019a0c7af 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3548,7 +3548,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()