From e2ba0e009e499e82b2922db7e58e91bc5f452d03 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sat, 3 Oct 2020 21:34:24 -0400 Subject: [PATCH] meson: Fix check for cairo and cairo-ft dependencies When cairo comes from a subproject fallback it should still take cairo-ft dependency, otherwise it miss freetype2 cflags. Also update wrap file to use upstream repository now that meson support has been merged. This requires Meson >= 0.54.0 because cairo itself requires that version and we use the new `fallback: 'cairo'` syntax without specifying a variable name because cairo does not provide a variable name for cairo-ft. --- meson.build | 37 +++++++++++++++++-------------------- subprojects/cairo.wrap | 4 ++-- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/meson.build b/meson.build index bf3925dbc..e3740df86 100644 --- a/meson.build +++ b/meson.build @@ -127,34 +127,31 @@ cairo_dep = null_dep cairo_ft_dep = null_dep if not get_option('cairo').disabled() cairo_dep = dependency('cairo', required: false) + cairo_ft_dep = dependency('cairo-ft', required: false) if (not cairo_dep.found() and cpp.get_id() == 'msvc' and cpp.has_header('cairo.h')) cairo_dep = cpp.find_library('cairo', required: false) + if cairo_dep.found() and cpp.has_function('cairo_ft_font_face_create_for_ft_face', + prefix: '#include ', + dependencies: cairo_dep) + cairo_ft_dep = cairo_dep + endif endif if not cairo_dep.found() - # Note that we don't have harfbuzz -> cairo -> freetype2 -> harfbuzz fallback - # dependency cycle here because we have configured freetype2 above with - # harfbuzz support disabled, so when cairo will lookup freetype2 dependency - # it will be forced to use that one. - cairo_dep = dependency('cairo', fallback: ['cairo', 'libcairo_dep'], - required: get_option('cairo')) - endif - - # Ensure that cairo-ft is fetched from the same library as cairo itself - if cairo_dep.found() - if cairo_dep.type_name() == 'internal' - # It is true at least for the port we have - cairo_ft_dep = cairo_dep - elif (cairo_dep.type_name() == 'library' and - cpp.has_function('cairo_ft_font_face_create_for_ft_face', - prefix: '#include ', - dependencies: cairo_dep)) - cairo_ft_dep = cairo_dep - else # including the most important type for us, 'pkgconfig' - cairo_ft_dep = dependency('cairo-ft', required: get_option('cairo')) + # Requires Meson 0.54.0 to use cairo subproject + if meson.version().version_compare('>=0.54.0') + # Note that we don't have harfbuzz -> cairo -> freetype2 -> harfbuzz fallback + # dependency cycle here because we have configured freetype2 above with + # harfbuzz support disabled, so when cairo will lookup freetype2 dependency + # it will be forced to use that one. + cairo_dep = dependency('cairo', fallback: 'cairo', required: get_option('cairo')) + cairo_ft_dep = dependency('cairo-ft', fallback: 'cairo', required: get_option('cairo')) + elif get_option('cairo').enabled() + error('cairo feature is enabled but it cannot be found on the system and ' + + 'meson>=0.54.0 is required to build it as subproject') endif endif endif diff --git a/subprojects/cairo.wrap b/subprojects/cairo.wrap index 2fd8fb19e..e6c7ea6ac 100644 --- a/subprojects/cairo.wrap +++ b/subprojects/cairo.wrap @@ -1,5 +1,5 @@ [wrap-git] directory=cairo -url=https://github.com/ebraminio/cairo.git +url=https://gitlab.freedesktop.org/cairo/cairo.git depth=1 -revision=meson +revision=master