builds: Require -Zc:preprocessor for Visual Studio debug builds

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.
This commit is contained in:
Chun-wei Fan
2023-10-24 14:54:19 +08:00
parent 25835afd9c
commit 8477dcfeff

View File

@@ -249,12 +249,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')