diff --git a/meson.build b/meson.build index 41f24b2cb..1bae27730 100644 --- a/meson.build +++ b/meson.build @@ -32,11 +32,16 @@ pkgmod = import('pkgconfig') cpp = meson.get_compiler('cpp') null_dep = dependency('', required: false) + +# Includes Microsoft Clang compiler with GNU arguments, see +# https://github.com/harfbuzz/harfbuzz/pull/4394 +cpp_is_microsoft_compiler = host_machine.system() == 'windows' and cpp.get_define('_MSC_FULL_VER') != '' + # Only perform these checks if cpp_std is c++11 as setting -std directly # produces a warning from meson. if get_option('cpp_std') == 'c++11' # Enforce C++14 requirement for MSVC STL - if cpp.get_id() == 'clang' and cpp.get_define('_MSC_FULL_VER') != '' + if cpp.get_id() == 'clang' and cpp_is_microsoft_compiler add_project_arguments('-std=c++14', language: 'cpp') elif cpp.get_id() == 'clang-cl' # Clang-cl produces a warning when using -std=c++14, but not when using /std:c++14 diff --git a/src/meson.build b/src/meson.build index 9d39b8f6f..daa821d77 100644 --- a/src/meson.build +++ b/src/meson.build @@ -599,7 +599,7 @@ defs_list = [harfbuzz_def] version = '0.@0@.0'.format(hb_version_int) extra_hb_cpp_args = [] -if cpp.get_define('_MSC_FULL_VER') != '' +if cpp_is_microsoft_compiler if get_option('default_library') != 'static' extra_hb_cpp_args += '-DHB_DLL_EXPORT' endif @@ -721,7 +721,7 @@ if get_option('tests').enabled() # TODO: Microsoft LINK gives the following because extern, non dllexport # symbols can only be used when linking against a static library # error LNK2019: unresolved external symbol "unsigned __int64 const * const _hb_NullPool" - if cpp.get_define('_MSC_FULL_VER') == '' + if not cpp_is_microsoft_compiler noinst_programs = { 'main': 'main.cc', 'test-basics': 'test.cc', @@ -768,7 +768,7 @@ if get_option('tests').enabled() 'test-unicode-ranges': ['test-unicode-ranges.cc'], } foreach name, source : compiled_tests - if cpp.get_define('_MSC_FULL_VER') != '' and source.contains('hb-static.cc') + if cpp_is_microsoft_compiler and source.contains('hb-static.cc') # TODO: Microsoft compilers cannot link tests using hb-static.cc, fix them continue endif