--- SDL2-2.0.12/CMakeLists.txt.orig	2020-04-12 15:07:13.379609100 +0300
+++ SDL2-2.0.12/CMakeLists.txt	2020-04-12 15:22:00.550760200 +0300
@@ -233,9 +233,17 @@
 
 # Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config,
 # etc. are created correctly.
-set(SDL_LIBS "-lSDL2")
+set(SDL_LIBS "")
 set(SDL_CFLAGS "")
 
+if(MINGW OR CYGWIN)
+  list(APPEND SDL_LIBS "-mwindows")
+endif()
+list(APPEND SDL_LIBS "-lSDL2")
+if(MINGW OR CYGWIN)
+  list(APPEND SDL_LIBS "-lSDL2main" "-lmingw32")
+endif()
+
 # When building shared lib for Windows with MinGW,
 # avoid the DLL having a "lib" prefix
 if(WINDOWS)
@@ -1508,7 +1516,6 @@
     list(APPEND EXTRA_LIBS mingw32)
     list(APPEND EXTRA_LDFLAGS "-mwindows")
     set(SDL_CFLAGS "${SDL_CFLAGS} -Dmain=SDL_main")
-    list(APPEND SDL_LIBS "-lmingw32" "-lSDL2main" "-mwindows")
   endif()
 
 elseif(APPLE)
