diff options
author | Simon McVittie <smcv@collabora.com> | 2022-07-25 14:30:02 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2022-07-26 17:08:56 +0000 |
commit | bc245968864d82e39d6fcb754ea84150a12be0a0 (patch) | |
tree | 70fb92f661a7bb94a2d65fb1588f57146fdd675d /meson.build | |
parent | 72d0a79ebab73ce05f691cf536f0a57bb6ffd693 (diff) | |
download | dbus-bc245968864d82e39d6fcb754ea84150a12be0a0.tar.gz |
meson: Only require C++ compiler when building for Windows
dbus is generally a C-only project, but the Windows side has a tiny
amount of C++ to initialize global locks (because Windows doesn't have
a direct equivalent of PTHREAD_MUTEX_INITIALIZER). We don't need a C++
compiler when building for a non-Windows OS, so there's no need to
find it or check which options it supports.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/meson.build b/meson.build index c6dbb578..034f0ce7 100644 --- a/meson.build +++ b/meson.build @@ -19,7 +19,7 @@ # SOFTWARE. project('dbus', - 'c', 'cpp', + 'c', version: '1.14.99', meson_version: '>=0.56', ) @@ -27,7 +27,6 @@ project('dbus', project_url = 'https://gitlab.freedesktop.org/dbus/dbus' cc = meson.get_compiler('c') -cpp = meson.get_compiler('cpp') windows = import('windows') pkgconfig = import('pkgconfig') @@ -87,6 +86,15 @@ host_os = host_machine.system() platform_windows = host_os.contains('windows') +if platform_windows + # On Windows, we use C++ constructors to initialize global locks + using_cpp = true + add_languages('cpp', required: true) + cpp = meson.get_compiler('cpp') +else + using_cpp = false +endif + platform_cygwin = host_os.contains('cygwin') # TODO: meson doesn't actually have WinCE support @@ -185,9 +193,12 @@ if cc.get_id() != 'msvc' endif compile_args_c = cc.get_supported_arguments(compile_args) -compile_args_cpp = cpp.get_supported_arguments(compile_args) add_project_arguments(compile_args_c, language: 'c') -add_project_arguments(compile_args_cpp, language: 'cpp') + +if using_cpp + compile_args_cpp = cpp.get_supported_arguments(compile_args) + add_project_arguments(compile_args_cpp, language: 'cpp') +endif if host_machine.endian() == 'big' config.set('WORDS_BIGENDIAN', 1) @@ -1052,12 +1063,16 @@ else endif compile_warnings_c = cc.get_supported_arguments(compile_warnings + compile_warnings_c) -compile_warnings_cpp = cpp.get_supported_arguments(compile_warnings) add_project_arguments(compile_warnings_c, language: 'c') -add_project_arguments(compile_warnings_cpp, language: 'cpp') link_args = cc.get_supported_link_arguments(link_args) -add_project_link_arguments(link_args, language: ['c', 'cpp']) +add_project_link_arguments(link_args, language: ['c']) + +if using_cpp + compile_warnings_cpp = cpp.get_supported_arguments(compile_warnings) + add_project_arguments(compile_warnings_cpp, language: 'cpp') + add_project_link_arguments(link_args, language: ['cpp']) +endif root_include = include_directories('.') @@ -1167,7 +1182,15 @@ summary_dict = { 'source code location': meson.project_source_root(), 'compiler': cc.get_id(), 'cflags': compile_args_c + compile_warnings_c, - 'cxxflags': compile_args_cpp + compile_warnings_cpp, +} + +if using_cpp + summary_dict += { + 'cxxflags': compile_args_cpp + compile_warnings_cpp, + } +endif + +summary_dict += { 'ldflags': (link_args.length() == 0) ? '[]' : link_args, '64-bit int': arch_config.get('DBUS_INT64_TYPE'), '32-bit int': arch_config.get('DBUS_INT32_TYPE'), |