builds: Require -Zc:preprocessor for Visual Studio debug builds
authorChun-wei Fan <fanchunwei@src.gnome.org>
Tue, 24 Oct 2023 06:54:19 +0000 (14:54 +0800)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 17 Nov 2023 19:54:13 +0000 (14:54 -0500)
This flag is actually required for the debugging code to successfully build,
so check that it is really there for debug-enabled Visual Studio builds.

meson.build

index 55d8dcc2be4851e062f0905a75d0bf287f6cebe2..0c42d4cb3ddc4202b97ad7d0e55db735a7bf6368 100644 (file)
@@ -248,12 +248,23 @@ endif
 
 # Compiler flags
 if cc.get_id() == 'msvc'
+  required_cflags = []
+  required_debug_cflags = '-Zc:preprocessor'
   test_cflags = [
     '-FI@0@/build-aux/msvc/msvc_recommended_pragmas.h'.format(meson.project_source_root()),
     '-D_USE_MATH_DEFINES',
-    '-Zc:preprocessor'
+    required_debug_cflags
   ]
-  add_project_arguments(cc.get_supported_arguments(test_cflags), language: 'c')
+  msvc_supported_cflags = cc.get_supported_arguments(test_cflags)
+  if debug
+    required_cflags += required_debug_cflags
+  endif
+  foreach f : required_cflags
+    if not msvc_supported_cflags.contains(f)
+      error('@0@ required for this build'.format(f))
+    endif
+  endforeach
+  add_project_arguments(msvc_supported_cflags, language: 'c')
 
   add_languages('cpp')
   cxx = meson.get_compiler('cpp')