From 561e8ba8870d9f18a92c886593f8b0162f98d941 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Thu, 17 Feb 2022 14:19:35 +0800 Subject: [PATCH 1/4] meson: Cleanup finding FreeType on Visual Studio Nowadays, CMake is much better supported with Meson and is a common tool on Windows (it is even an optionally-installed item for Visual Studio 2017+), so make use of that to find FreeType. The package to search for, however, is `freetype` instead of `freetype2`. --- meson.build | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/meson.build b/meson.build index 8a9400cdb..917c4d019 100644 --- a/meson.build +++ b/meson.build @@ -83,22 +83,10 @@ check_funcs = [ m_dep = cpp.find_library('m', required: false) -freetype_dep = null_dep -if not get_option('freetype').disabled() - freetype_dep = dependency('freetype2', required: false) - - if (not freetype_dep.found() and - cpp.get_id() == 'msvc' and - cpp.has_header('ft2build.h')) - freetype_dep = cpp.find_library('freetype', required: false) - endif - - if not freetype_dep.found() - # https://github.com/harfbuzz/harfbuzz/pull/2498 - freetype_dep = dependency('freetype2', required: get_option('freetype'), - default_options: ['harfbuzz=disabled']) - endif -endif +# https://github.com/harfbuzz/harfbuzz/pull/2498 +freetype_dep = dependency(cpp.get_argument_syntax() == 'msvc' ? 'freetype' : 'freetype2', + required: get_option('freetype'), + default_options: ['harfbuzz=disabled']) glib_dep = dependency('glib-2.0', required: get_option('glib')) gobject_dep = dependency('gobject-2.0', required: get_option('gobject')) From f0573d8462ef18bd21c6ae3fc7d2c15c660ff1c7 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Thu, 17 Feb 2022 14:39:31 +0800 Subject: [PATCH 2/4] meson: Clean up finding ICU-UC on Visual Studio Nowadays Meson has much better CMake support which we can use to find dependencies on Visual Studio builds (and Visual Studio 2017 and later provides CMake as an optional install item), so we can use it to help us find ICU-UC on Visual Studio builds, since CMake has built-in support for finding it by the components we need for some time. --- meson.build | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/meson.build b/meson.build index 917c4d019..e22859a26 100644 --- a/meson.build +++ b/meson.build @@ -93,28 +93,15 @@ gobject_dep = dependency('gobject-2.0', required: get_option('gobject')) graphite2_dep = dependency('graphite2', required: get_option('graphite2')) graphite_dep = dependency('graphite2', required: get_option('graphite')) -icu_dep = null_dep -if not get_option('icu').disabled() - icu_dep = dependency('icu-uc', required: false) - - if (not icu_dep.found() and - cpp.get_id() == 'msvc' and - cpp.has_header('unicode/uchar.h') and - cpp.has_header('unicode/unorm2.h') and - cpp.has_header('unicode/ustring.h') and - cpp.has_header('unicode/utf16.h') and - cpp.has_header('unicode/uversion.h') and - cpp.has_header('unicode/uscript.h')) - if get_option('buildtype') == 'debug' - icu_dep = cpp.find_library('icuucd', required: false) - else - icu_dep = cpp.find_library('icuuc', required: false) - endif - endif - - if not icu_dep.found() - icu_dep = dependency('icu-uc', required: get_option('icu')) - endif +if cpp.get_argument_syntax() == 'msvc' + icu_dep = dependency('ICU', + required: get_option('icu'), + components: 'uc', + method: 'cmake') +else + icu_dep = dependency('icu-uc', + required: get_option('icu'), + method: 'pkg-config') endif if icu_dep.found() and icu_dep.type_name() == 'pkgconfig' From d24ac4aac33bee06082c6bfcca907569740c7f59 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Thu, 17 Feb 2022 16:18:41 +0800 Subject: [PATCH 3/4] freetype2.wrap: Provide fallback for CMake dep as well Add a freetype identifier in the 'provides' section so that the fallback will kick in if FreeType is requested but was not found, and wrap mode is not disabled. --- subprojects/freetype2.wrap | 1 + 1 file changed, 1 insertion(+) diff --git a/subprojects/freetype2.wrap b/subprojects/freetype2.wrap index cf8f30701..43ab8fa47 100644 --- a/subprojects/freetype2.wrap +++ b/subprojects/freetype2.wrap @@ -5,3 +5,4 @@ revision=VER-2-11-0 [provide] freetype2 = freetype_dep +freetype = freetype_dep From e6aa4b7d0e3026f3186738b1e8b50286988ba38f Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Thu, 17 Feb 2022 15:28:42 +0800 Subject: [PATCH 4/4] BUILD.md: Mention that installing CMake is recommended for MSVC We are using CMake to help us find dependencies in Meson builds on Visual Studio, so let people know that it's recommended. --- BUILD.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BUILD.md b/BUILD.md index f64f8687d..47681ec86 100644 --- a/BUILD.md +++ b/BUILD.md @@ -18,7 +18,8 @@ meson like above. On Windows, meson can build the project like above if a working MSVC's cl.exe (`vcvarsall.bat`) or gcc/clang is already on your path, and if you use something like `meson build --wrap-mode=default` -it fetches and compiles most of the dependencies also. +it fetches and compiles most of the dependencies also. It is recommended to install CMake either +manually or via the Visual Studio installer when building with MSVC when building with meson. Our CI configurations is also a good source of learning how to build HarfBuzz.