[babl/wip/msvc: 3/20] meson.build: Check for some MSVC specific items



commit ac83741410077fc28155c96af44be8d8bbdeaa8d
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Jan 17 15:45:37 2020 +0800

    meson.build: Check for some MSVC specific items
    
    This will allow the code to build as we are:
    
    -Using some math macros that requires -D_USE_MATH_DEFINES to enable
    -Using unicode sequences that will cause C4819 warnings on certain
     locales of Windows (note: CJK), which can lead to miscompilations.
    -Using ssize_t, which is not provided by Visual Studio as it is
     actually from POSIX, not standard C
    
    We also want to silence some spurious compiler warnings as well.

 meson.build | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/meson.build b/meson.build
index 626324717..58acf8a50 100644
--- a/meson.build
+++ b/meson.build
@@ -171,6 +171,24 @@ extra_warnings_list = [
 ]
 common_c_flags += cc.get_supported_arguments(extra_warnings_list)
 
+if cc.get_id() == 'msvc'
+  msvc_cflags = [
+    '-utf-8',              # Avoid C4819 (Unicode handling) compiler warnings
+    '-D_USE_MATH_DEFINES', # Allow more math macro usage
+    '-wd4244',             # Silence some unneeded compiler warnings
+    '-wd4305'
+  ]
+
+  # MSVC does not come with ssize_t
+  if host_cpu_family == 'x86_64' or host_cpu_family == 'arm64'
+    msvc_cflags += '-Dssize_t=signed __int64'
+  else
+    msvc_cflags += '-Dssize_t=signed int'
+  endif
+
+  common_c_flags += cc.get_supported_arguments(msvc_cflags)
+endif
+
 add_project_arguments(common_c_flags, language: 'c')
 
 ################################################################################


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