Fix cross build with mingw32
authorXavier Claessens <xavier.claessens@collabora.com>
Thu, 24 Mar 2022 18:15:00 +0000 (14:15 -0400)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 1 Apr 2022 15:52:28 +0000 (15:52 +0000)
At least on Ubuntu 20.04 the x86_64-w64-mingw32-gcc toolchain defaults
to WinXP. We require at least Vista for FILE_STANDARD_INFO.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2022>

subprojects/gst-plugins-bad/ext/sctp/usrsctp/meson.build
subprojects/gst-plugins-bad/meson.build
subprojects/gstreamer/meson.build

index 8d47497..0869dd5 100644 (file)
@@ -77,7 +77,6 @@ elif system == 'windows'
     if compiler.get_id() == 'gcc'
         compile_args += [compiler.get_supported_arguments([
             '-Wno-format',
-            '-D_WIN32_WINNT=0x601',  # Enables inet_ntop and friends
         ])]
     endif
 else
index ce1918e..0d5b66c 100644 (file)
@@ -408,6 +408,23 @@ endif
 
 if host_machine.system() == 'windows'
   winsock2 = [cc.find_library('ws2_32')]
+
+  building_for_win7 = cc.compiles('''#include <windows.h>
+      #ifndef WINVER
+      #error "unknown minimum supported OS version"
+      #endif
+      #if (WINVER < _WIN32_WINNT_WIN7)
+      #error "Windows 7 API is not guaranteed"
+      #endif
+      ''',
+      name: 'building for Windows 7')
+
+  if not building_for_win7
+    add_project_arguments([
+      '-D_WIN32_WINNT=_WIN32_WINNT_WIN7',
+      '-DWINVER=_WIN32_WINNT_WIN7',
+    ], language: ['c', 'cpp'])
+  endif
 else
   winsock2 = []
 endif
index ae2ca58..46551c7 100644 (file)
@@ -404,6 +404,23 @@ if host_system == 'windows'
   if cc.compiles(code, name : 'building for UWP')
     building_for_uwp = true
   endif
+
+  building_for_win7 = cc.compiles('''#include <windows.h>
+      #ifndef WINVER
+      #error "unknown minimum supported OS version"
+      #endif
+      #if (WINVER < _WIN32_WINNT_WIN7)
+      #error "Windows 7 API is not guaranteed"
+      #endif
+      ''',
+      name: 'building for Windows 7')
+
+  if not building_for_win7
+    add_project_arguments([
+      '-D_WIN32_WINNT=_WIN32_WINNT_WIN7',
+      '-DWINVER=_WIN32_WINNT_WIN7',
+    ], language: ['c', 'cpp'])
+  endif
 endif
 
 backtrace_deps = []