[glib: 2/5] windows: Move G_WINAPI_ONLY_APP to config.h



commit f84ef0291402303a9e23cf1008f6e6b0ea653331
Author: Nirbheek Chauhan <nirbheek centricular com>
Date:   Wed Aug 14 10:43:49 2019 +0530

    windows: Move G_WINAPI_ONLY_APP to config.h
    
    Also set the Windows version to be 10 or newer when targeting UWP, since
    the Windows 8 SDK does not have many of the APIs we need, such as
    _beginthreadex.

 gmodule/gmodule-win32.c |  6 ------
 meson.build             | 17 +++++++++++++++--
 2 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/gmodule/gmodule-win32.c b/gmodule/gmodule-win32.c
index 1c7226a68..3cddb614a 100644
--- a/gmodule/gmodule-win32.c
+++ b/gmodule/gmodule-win32.c
@@ -39,12 +39,6 @@
 #include <sys/cygwin.h>
 #endif
 
-/* Default family is DESKTOP_APP which is DESKTOP | APP
- * We want to know when we're only building for apps */
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-#define G_WINAPI_ONLY_APP
-#endif
-
 static void
 set_error (const gchar *format,
           ...)
diff --git a/meson.build b/meson.build
index 9bcf732bf..b9ce8c73b 100644
--- a/meson.build
+++ b/meson.build
@@ -400,9 +400,22 @@ add_project_arguments(cc.get_supported_arguments(warning_c_args), language: 'c')
 # improve this.
 glib_link_flags = cc.get_supported_link_arguments(warning_c_link_args)
 
-# Windows Support (7+)
+# Windows SDK requirements and checks
 if host_system == 'windows'
-  glib_conf.set('_WIN32_WINNT', '0x0601')
+  # Check whether we're building for UWP apps
+  code = '''
+  #include <windows.h>
+  #if !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
+  #error "Not building for UWP"
+  #endif'''
+  if cc.compiles(code, name : 'building for UWP')
+    glib_conf.set('G_WINAPI_ONLY_APP', true)
+    # We require Windows 10+ on WinRT
+    glib_conf.set('_WIN32_WINNT', '0x0A00')
+  else
+    # We require Windows 7+ on Win32
+    glib_conf.set('_WIN32_WINNT', '0x0601')
+  endif
 endif
 
 functions = [


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]