Skip to content

Commit 4c0f262

Browse files
committed
Meson build: Better detection of MSVC-like compilers
Treat all compilers with MSVC-like argument syntax the same. Use cpp_compiler.get_define('_MSC_VER') instead of cpp_compiler.version() to check compiler version. Suggested by Tim-Philipp Müller and Chun-wei Fan. See https://gitlab.freedesktop.org/cairo/cairomm/-/merge_requests/30
1 parent 60c382e commit 4c0f262

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

meson.build

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,12 @@ project_build_root = meson.current_build_dir()
4040

4141
cpp_compiler = meson.get_compiler('cpp')
4242
cpp_compiler_id = cpp_compiler.get_id()
43-
is_msvc = cpp_compiler_id == 'msvc' or cpp_compiler_id.endswith('-cl')
44-
is_cl_impersonator = is_msvc and cpp_compiler_id != 'msvc'
43+
is_msvc_style = cpp_compiler.get_argument_syntax() == 'msvc'
4544
python3 = find_program('python3', version: '>=3.7')
4645

47-
# MSVC: We currently do not support shared and static builds at the,
48-
# same time, since we need different defines/cflags for proper
49-
# linking.
50-
if is_msvc
46+
# MSVC: We currently do not support shared and static builds at the same time,
47+
# since we need different defines/cflags for proper linking.
48+
if is_msvc_style
5149
if get_option('default_library') == 'both'
5250
error('-Ddefault_library=both is currently not supported for Visual Studio')
5351
endif
@@ -120,11 +118,11 @@ benchmark_dep = dependency('boost', modules: ['system', 'timer'],
120118
version: '>=1.20.0', required: do_benchmark)
121119
can_benchmark = benchmark_dep.found()
122120

123-
if is_msvc and not is_cl_impersonator
121+
if is_msvc_style
124122
# We must have Visual Studio 2017 15.7 or later...
125-
assert(cpp_compiler.version().split('.')[0].to_int() >= 19 and \
126-
cpp_compiler.version().split('.')[1].to_int() >= 15,
127-
'Visual Studio 2017 15.7 or later is required')
123+
mscver = cpp_compiler.get_define('_MSC_VER')
124+
assert(mscver == '' or mscver.version_compare('>=1914'),
125+
'Visual Studio 2017 15.7 or later or compatible is required')
128126
endif
129127

130128
# Some dependencies are required only in maintainer mode and/or
@@ -185,17 +183,17 @@ endif
185183
warning_flags = []
186184
if cpp_warnings == 'min'
187185
if warning_level == 0
188-
warning_flags = is_msvc ? ['/W2'] : ['-Wall']
189-
endif
186+
warning_flags = is_msvc_style ? ['/W2'] : ['-Wall']
187+
endif
190188
elif cpp_warnings == 'max' or cpp_warnings == 'fatal'
191189
if warning_level < 3
192-
warning_flags = is_msvc ? ['/W4'] : ['-pedantic', '-Wall', '-Wextra']
190+
warning_flags = is_msvc_style ? ['/W4'] : ['-pedantic', '-Wall', '-Wextra']
193191
endif
194-
if not is_msvc
192+
if not is_msvc_style
195193
warning_flags += '-Wsuggest-override -Wshadow -Wzero-as-null-pointer-constant -Wformat-security'.split()
196194
endif
197195
if cpp_warnings == 'fatal' and not werror
198-
warning_flags += is_msvc ? ['/WX'] : ['-Werror']
196+
warning_flags += is_msvc_style ? ['/WX'] : ['-Werror']
199197
endif
200198
endif
201199

@@ -206,7 +204,7 @@ add_project_arguments(warning_flags, language: 'cpp')
206204
# that should not be overlooked stand out.
207205
static_cxxflag = '-DLIBSIGCXX_STATIC'
208206
msvc_static_cxxflag = is_msvc_static ? static_cxxflag : ''
209-
if is_msvc
207+
if is_msvc_style
210208
disable_warnings_list = [
211209
'/EHsc', # avoid warnings caused by exception handling model used
212210
]

sigc++/meson.build

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# sigc++
22

33
# Input: sigcxx_build_dep, sigcxx_pcname, sigcxx_libversion, sigcxx_api_version,
4-
# darwin_versions, install_includedir, sig_rc, msvc_static_cxxflag
4+
# darwin_versions, install_includedir, sig_rc, msvc_static_cxxflag,
5+
# is_msvc_style
56
# Output: source_h_files, sigcxx_own_dep
67

78
# There are no built source files in libsigc++-3.0.
@@ -75,7 +76,7 @@ extra_sigc_cppflags = []
7576
extra_sigc_objects = []
7677

7778
# Make sure we are exporting the symbols from the DLL
78-
if is_msvc
79+
if is_msvc_style
7980
extra_sigc_cppflags += ['-DSIGC_BUILD']
8081
endif
8182

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy