SDL: cmake: allow users of sdl2-config.cmake to not add -mwindows to the link options

From 535ec1a9217ec7587e384b06e10027323c70c03a Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Tue, 18 Apr 2023 18:46:35 +0200
Subject: [PATCH] cmake: allow users of sdl2-config.cmake to not add -mwindows
 to the link options

---
 sdl2-config.cmake.in | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sdl2-config.cmake.in b/sdl2-config.cmake.in
index d75f8b470944..842f826bb5a3 100644
--- a/sdl2-config.cmake.in
+++ b/sdl2-config.cmake.in
@@ -60,6 +60,11 @@ string(REGEX MATCHALL "-L([-a-zA-Z0-9._/]+)" _sdl2_static_private_libdirs "${_sd
 string(REGEX REPLACE "^-L" "" _sdl2_static_private_libdirs "${_sdl2_static_private_libdirs}")
 string(REGEX REPLACE ";-L" ";" _sdl2_static_private_libdirs "${_sdl2_static_private_libdirs}")
 
+# Set SDL2_NO_MWINDOWS to a true-ish value to not add the -mwindows link option
+if(SDL2_NO_MWINDOWS)
+  list(REMOVE_ITEM _sdl2_libraries "-mwindows")
+endif()
+
 if(_sdl2_libraries MATCHES ".*SDL2main.*")
   list(INSERT SDL2_LIBRARIES 0 SDL2::SDL2main)
   list(INSERT SDL2_STATIC_LIBRARIES 0 SDL2::SDL2main)