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.
This commit is contained in:
Xavier Claessens 2020-10-03 21:34:24 -04:00
parent c4ade4fdd6
commit e2ba0e009e
2 changed files with 19 additions and 22 deletions

View File

@ -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 <cairo-ft.h>',
dependencies: cairo_dep)
cairo_ft_dep = cairo_dep
endif
endif
if not cairo_dep.found()
# 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', '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 <cairo-ft.h>',
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'))
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

View File

@ -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