Commit 18206446bfdcaf8c549e09b2bfcd139dabfe096f

Anonymous Maarten 2022-06-15T17:10:31

cmake: collect SDL_LIBS as list + export PKG_DIRECTFB_LDFLAGS

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3435f03..7982b91 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -296,7 +296,7 @@ endif()
 # 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_CFLAGS "")
+set(SDL_CFLAGS )
 
 # When building shared lib for Windows with MinGW,
 # avoid the DLL having a "lib" prefix
@@ -321,7 +321,7 @@ if(CYGWIN)
     list(APPEND EXTRA_LDFLAGS_BUILD "-mno-cygwin")
     list(APPEND SDL_LIBS "-mno-cygwin")
   endif()
-  set(SDL_CFLAGS "${SDL_CFLAGS} -I/usr/include/mingw")
+  list(APPEND SDL_CFLAGS "-I/usr/include/mingw")
 endif()
 
 # General includes
@@ -1859,7 +1859,7 @@ elseif(WINDOWS)
   if(MINGW OR CYGWIN)
     list(APPEND SDL_LIBS "-lmingw32" "-mwindows")
     if(NOT SDL2_DISABLE_SDL2MAIN)
-      set(SDL_CFLAGS "${SDL_CFLAGS} -Dmain=SDL_main")
+      list(APPEND SDL_CFLAGS "-Dmain=SDL_main")
       list(APPEND SDL_LIBS "-lSDL2main")
     endif(NOT SDL2_DISABLE_SDL2MAIN)
   endif()
@@ -2758,6 +2758,8 @@ Libs.private:")
     listtostr(SDL_LIBS _SDL_LIBS)
     set(SDL_LIBS ${_SDL_LIBS})
   endif()
+  listtostr(SDL_CFLAGS _SDL_CFLAGS "")
+  set(SDL_CFLAGS ${_SDL_CFLAGS})
 
   # MESSAGE(STATUS "SDL_LIBS: ${SDL_LIBS}")
   # MESSAGE(STATUS "SDL_STATIC_LIBS: ${SDL_STATIC_LIBS}")
diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index b812f6a..57962e6 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -733,6 +733,7 @@ macro(CheckDirectFB)
       set(SDL_VIDEO_DRIVER_DIRECTFB 1)
       set(SDL_VIDEO_RENDER_DIRECTFB 1)
       list(APPEND EXTRA_CFLAGS ${PKG_DIRECTFB_CFLAGS})
+      list(APPEND SDL_CFLAGS ${PKG_DIRECTFB_CFLAGS})
       if(SDL_DIRECTFB_SHARED AND NOT HAVE_SDL_LOADSO)
         message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading")
       endif()
@@ -773,7 +774,7 @@ macro(CheckVivante)
         find_library(VIVANTE_VDK_LIBRARY VDK REQUIRED)
         list(APPEND EXTRA_LIBS ${VIVANTE_LIBRARY} ${VIVANTE_VDK_LIBRARY})
       else()
-        set(SDL_CFLAGS "${SDL_CFLAGS} -DLINUX -DEGL_API_FB")
+        list(APPEND SDL_CFLAGS -DLINUX -DEGL_API_FB)
         list(APPEND EXTRA_LIBS EGL)
       endif(HAVE_VIVANTE_VDK)
     endif()
@@ -921,8 +922,7 @@ macro(CheckPTHREAD)
       set(SDL_THREAD_PTHREAD 1)
       list(APPEND EXTRA_CFLAGS ${PTHREAD_CFLAGS})
       list(APPEND EXTRA_LDFLAGS ${PTHREAD_LDFLAGS})
-      set(SDL_CFLAGS "${SDL_CFLAGS} ${PTHREAD_CFLAGS}")
-      list(APPEND SDL_LIBS ${PTHREAD_LDFLAGS})
+      list(APPEND SDL_CFLAGS ${PTHREAD_CFLAGS})
 
       check_c_source_compiles("
         #define _GNU_SOURCE 1