[gtk/master.msvc: 19/19] meson/MSVC builds: Use -utf-8 where available



commit 7a1c03109cf4aaa0d927be283c874fc67e70a3f8
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Jan 15 15:27:59 2020 +0800

    meson/MSVC builds: Use -utf-8 where available
    
    This avoids the build from erroring out on C4819 (Unicode handling issue in
    Visual Studio compiler), notably when running on Chinese, Japanese and
    Korean locales.
    
    Also apply -D_USE_MATH_DEFINES, -FImsvc_recommended_pragmas.h and -utf-8 to
    the C++ compiler options as well.

 meson.build | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/meson.build b/meson.build
index 1c3b93aab9..c0bd059813 100644
--- a/meson.build
+++ b/meson.build
@@ -134,6 +134,7 @@ gtk_schemasdir = join_paths(gtk_datadir, 'glib-2.0/schemas')
 gtk_appdatadir = join_paths(gtk_datadir, 'metainfo')
 
 cc = meson.get_compiler('c')
+cxx = meson.get_compiler('cpp')
 
 cdata = configuration_data()
 cdata.set_quoted('PACKAGE_VERSION', meson.project_version())
@@ -223,9 +224,15 @@ endif
 if cc.get_id() == 'msvc'
   # Compiler options taken from msvc_recommended_pragmas.h
   # in GLib, based on _Win32_Programming_ by Rector and Newcomer
-  test_cflags = []
-  add_project_arguments('-FImsvc_recommended_pragmas.h', language: 'c')
-  add_project_arguments('-D_USE_MATH_DEFINES', language: 'c')
+  test_cflags = [
+    '-FImsvc_recommended_pragmas.h',
+       '-D_USE_MATH_DEFINES',
+       '-utf-8',
+  ]
+  add_project_arguments(cc.get_supported_arguments(test_cflags), language: 'c')
+  if cxx.get_id() == 'msvc'
+    add_project_arguments(cxx.get_supported_arguments(test_cflags), language: 'cpp')
+  endif
 elif cc.get_id() == 'gcc' or cc.get_id() == 'clang'
   test_cflags = [
     '-fno-strict-aliasing',


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