[Mesa-dev] [PATCH v3 13/48] meson: add windows compiler checks and libraries
Dylan Baker
dylan at pnwbakers.com
Tue Aug 7 00:50:53 UTC 2018
---
meson.build | 129 ++++++++++++++++++++++++++++++++--------------------
1 file changed, 79 insertions(+), 50 deletions(-)
diff --git a/meson.build b/meson.build
index 25de31bfabd..4350e1af810 100644
--- a/meson.build
+++ b/meson.build
@@ -775,69 +775,96 @@ endif
# TODO: this is very incomplete
if ['linux', 'cygwin'].contains(host_machine.system())
pre_args += '-D_GNU_SOURCE'
+elif host_machine.system() == 'windows'
+ pre_args += [
+ '-D_WINDOWS', '-D_WIN32_WINNT=0x0601', '-D_WINVER=0x0601',
+ '-DPIPE_SUBSYSTEM_WINDOWS_USER',
+ '-D_USE_MATH_DEFINES', # XXX: scons doesn't use this for mingw
+ ]
+ if cc.get_id() == 'msvc'
+ pre_args += [
+ '-DVC_EXTRALEAN',
+ '-D_CRT_SECURE_NO_WARNINGS',
+ '-D_CRT_SECURE_NO_DEPRECATE',
+ '-D_SCL_SECURE_NO_WARNINGS',
+ '-D_SCL_SECURE_NO_DEPRECATE',
+ '-D_ALLOW_KEYWORD_MACROS',
+ '-D_HAS_EXCEPTIONS=0', # Tell C++ STL to not use exceptions
+ ]
+ else
+ pre_args += ['-D__MSVCRT_VERSION__=0x0700']
+ endif
endif
# Check for generic C arguments
c_args = []
-foreach a : ['-Wall', '-Werror=implicit-function-declaration',
- '-Werror=missing-prototypes', '-fno-math-errno',
- '-fno-trapping-math', '-Qunused-arguments']
- if cc.has_argument(a)
- c_args += a
- endif
-endforeach
-if cc.has_argument('-Wmissing-field-initializers')
- c_args += '-Wno-missing-field-initializers'
-endif
-
c_vis_args = []
-if cc.has_argument('-fvisibility=hidden')
- c_vis_args += '-fvisibility=hidden'
-endif
-
-# Check for generic C++ arguments
+c_msvc_compat_args = []
+no_override_init_args = []
cpp_args = []
-foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
- '-Qunused-arguments']
- if cpp.has_argument(a)
- cpp_args += a
+cpp_vis_args = []
+cpp_msvc_compat_args = []
+if cc.get_id() == 'msvc'
+ foreach a : ['/wd4018', '/wd4056', '/wd4244', '/wd4246', '/wd4305',
+ '/wd4351', '/wd4756', '/wd4800', '/wd4996']
+ if cc.has_argument(a)
+ c_args += a
+ endif
+ if cpp.has_argument(a)
+ cpp_args += a
+ endif
+ endforeach
+ if cc.has_argument('-Wmicrosoft-enum-value') # Clang
+ c_args += '-Wno-microsoft-enum-value'
+ cpp_args += '-Wno-microsoft-enum-value'
endif
-endforeach
-
-# For some reason, the test for -Wno-foo always succeeds with gcc, even if the
-# option is not supported. Hence, check for -Wfoo instead.
-
-foreach a : ['non-virtual-dtor', 'missing-field-initializers']
- if cpp.has_argument('-W' + a)
- cpp_args += '-Wno-' + a
+else
+ foreach a : ['-Wall', '-Werror=implicit-function-declaration',
+ '-Werror=missing-prototypes', '-fno-math-errno',
+ '-fno-trapping-math', '-Qunused-arguments']
+ if cc.has_argument(a)
+ c_args += a
+ endif
+ endforeach
+ if cc.has_argument('-Wmissing-field-initializers')
+ c_args += '-Wno-missing-field-initializers'
endif
-endforeach
-no_override_init_args = []
-foreach a : ['override-init', 'initializer-overrides']
- if cc.has_argument('-W' + a)
- no_override_init_args += '-Wno-' + a
+ c_vis_args = []
+ if cc.has_argument('-fvisibility=hidden')
+ c_vis_args += '-fvisibility=hidden'
endif
-endforeach
-cpp_vis_args = []
-if cpp.has_argument('-fvisibility=hidden')
- cpp_vis_args += '-fvisibility=hidden'
-endif
+ # For some reason, the test for -Wno-foo always succeeds with gcc, even if
+ # the option is not supported. Hence, check for -Wfoo instead.
+ foreach a : ['non-virtual-dtor', 'missing-field-initializers']
+ if cpp.has_argument('-W' + a)
+ cpp_args += '-Wno-' + a
+ endif
+ endforeach
-# Check for C and C++ arguments for MSVC2013 compatibility. These are only used
-# in parts of the mesa code base that need to compile with old versions of
-# MSVC, mainly common code
-c_msvc_compat_args = []
-cpp_msvc_compat_args = []
-foreach a : ['-Werror=pointer-arith', '-Werror=vla']
- if cc.has_argument(a)
- c_msvc_compat_args += a
- endif
- if cpp.has_argument(a)
- cpp_msvc_compat_args += a
+ foreach a : ['override-init', 'initializer-overrides']
+ if cc.has_argument('-W' + a)
+ no_override_init_args += '-Wno-' + a
+ endif
+ endforeach
+
+ if cpp.has_argument('-fvisibility=hidden')
+ cpp_vis_args += '-fvisibility=hidden'
endif
-endforeach
+
+ # Check for C and C++ arguments for MSVC2013 compatibility. These are only
+ # used in parts of the mesa code base that need to compile with old versions
+ # of MSVC, mainly common code
+ foreach a : ['-Werror=pointer-arith', '-Werror=vla']
+ if cc.has_argument(a)
+ c_msvc_compat_args += a
+ endif
+ if cpp.has_argument(a)
+ cpp_msvc_compat_args += a
+ endif
+ endforeach
+endif
if host_machine.cpu_family().startswith('x86')
pre_args += '-DUSE_SSE41'
@@ -896,6 +923,8 @@ if not cc.links('''#include <stdint.h>
pre_args += '-DMISSING_64_BIT_ATOMICS'
endif
+dep_ws2_32 = cc.find_library('ws2_32', required : with_platform_windows)
+
# TODO: shared/static? Is this even worth doing?
# When cross compiling we generally need to turn off the use of assembly,
--
2.18.0
More information about the mesa-dev
mailing list