mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-04 23:28:07 +02:00
meson: Use pkgmod.generate() for all cairo pc files
Also override each dependency so they can be used when cairo is used as subproject.
This commit is contained in:
parent
e2c1b76d71
commit
084404cd15
3 changed files with 100 additions and 150 deletions
234
meson.build
234
meson.build
|
|
@ -1,5 +1,5 @@
|
|||
project('cairo', 'c', 'cpp',
|
||||
meson_version: '>= 0.50.0',
|
||||
meson_version: '>= 0.54.0',
|
||||
version: '1.17.3',
|
||||
)
|
||||
|
||||
|
|
@ -163,12 +163,12 @@ if png_dep.found()
|
|||
{
|
||||
'name': 'cairo-png',
|
||||
'description': 'PNG functions',
|
||||
'requires': 'libpng',
|
||||
'deps': [png_dep],
|
||||
},
|
||||
{
|
||||
'name': 'cairo-svg',
|
||||
'description': 'SVG surface backend',
|
||||
'requires': 'libpng',
|
||||
'deps': [png_dep],
|
||||
}
|
||||
]
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ if freetype_dep.found()
|
|||
built_features += [{
|
||||
'name': 'cairo-ft',
|
||||
'description': 'Freetype font backend',
|
||||
'requires': 'freetype2 @0@'.format(freetype_required_version)
|
||||
'deps': [freetype_dep],
|
||||
}]
|
||||
|
||||
ft_check_funcs = [
|
||||
|
|
@ -241,7 +241,7 @@ if fontconfig_dep.found()
|
|||
built_features += [{
|
||||
'name': 'cairo-fc',
|
||||
'description': 'Fontconfig font backend',
|
||||
'requires': 'fontconfig @0@'.format(fontconfig_required_version)
|
||||
'deps': [fontconfig_dep],
|
||||
}]
|
||||
endif
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ if x11_dep.found() and xext_dep.found()
|
|||
built_features += [{
|
||||
'name': 'cairo-xlib',
|
||||
'description': 'Xlib surface backend',
|
||||
'requires': 'x11 xext',
|
||||
'deps': [x11_dep, xext_dep],
|
||||
}]
|
||||
|
||||
extra_headers = ['X11/Xlibint.h', 'X11/Xproto.h']
|
||||
|
|
@ -288,7 +288,7 @@ if feature_conf.get('CAIRO_HAS_XLIB_SURFACE', 0) == 1
|
|||
built_features += [{
|
||||
'name': 'cairo-xlib-xrender',
|
||||
'description': 'Xlib Xrender surface backend',
|
||||
'requires': 'xrender @0@'.format(xrender_required_version),
|
||||
'deps': [xrender_dep],
|
||||
}]
|
||||
feature_conf.set('CAIRO_HAS_XLIB_XRENDER_SURFACE', 1)
|
||||
endif
|
||||
|
|
@ -303,7 +303,7 @@ if xcb_dep.found() and xcb_render_dep.found()
|
|||
built_features += [{
|
||||
'name': 'cairo-xcb',
|
||||
'description': 'XCB surface backend',
|
||||
'requires': 'xcb @0@ xcb-render @1@'.format(xcb_required_version, xcb_render_required_version),
|
||||
'deps': [xcb_dep, xcb_render_dep],
|
||||
}]
|
||||
|
||||
deps += [xcb_dep, xcb_render_dep]
|
||||
|
|
@ -318,7 +318,7 @@ if feature_conf.get('CAIRO_HAS_XCB_SURFACE', 0) == 1 and feature_conf.get('CAIRO
|
|||
built_features += [{
|
||||
'name': 'cairo-xlib-xcb',
|
||||
'description': 'Xlib/XCB functions',
|
||||
'requires': 'x11-xcb',
|
||||
'deps': [x11xcb_dep],
|
||||
}]
|
||||
endif
|
||||
endif
|
||||
|
|
@ -331,7 +331,7 @@ if feature_conf.get('CAIRO_HAS_XCB_SURFACE', 0) == 1
|
|||
built_features += [{
|
||||
'name': 'cairo-xcb-shm',
|
||||
'description': 'XCB/SHM functions',
|
||||
'requires': 'xcb-shm',
|
||||
'deps': [xcbshm_dep],
|
||||
}]
|
||||
endif
|
||||
endif
|
||||
|
|
@ -344,13 +344,10 @@ if qtgui_dep.found() and false
|
|||
built_features += [{
|
||||
'name': 'cairo-qt',
|
||||
'description': 'Qt surface backend',
|
||||
'requires': 'QtGui @0@'.format(qtgui_required_version),
|
||||
'libs': qtgui_extra_libs,
|
||||
'deps': [qtgui_dep],
|
||||
}]
|
||||
|
||||
deps += [qtgui_dep]
|
||||
qtgui_extra_libs = ['-lstdc++']
|
||||
extra_link_args += qtgui_extra_libs
|
||||
endif
|
||||
|
||||
# Untested
|
||||
|
|
@ -387,27 +384,28 @@ if cc.has_header('ApplicationServices/ApplicationServices.h')
|
|||
endif
|
||||
|
||||
if host_machine.system() == 'windows'
|
||||
win32_extra_libs = []
|
||||
foreach libname: ['gdi32', 'msimg32']
|
||||
deps += [cc.find_library(libname)]
|
||||
win32_extra_libs += ['-l' + libname]
|
||||
endforeach
|
||||
win32_extra_deps = [
|
||||
cc.find_library('gdi32'),
|
||||
cc.find_library('msimg32'),
|
||||
]
|
||||
|
||||
deps += win32_extra_deps
|
||||
|
||||
feature_conf.set('CAIRO_HAS_WIN32_SURFACE', 1)
|
||||
built_features += [{
|
||||
'name': 'cairo-win32',
|
||||
'description': 'Microsoft Windows surface backend',
|
||||
'libs': win32_extra_libs,
|
||||
}]
|
||||
endif
|
||||
|
||||
if feature_conf.get('CAIRO_HAS_WIN32_SURFACE', 0) == 1
|
||||
feature_conf.set('CAIRO_HAS_WIN32_FONT', 1)
|
||||
built_features += [{
|
||||
'name': 'cairo-win32-font',
|
||||
'description': 'Microsoft Windows font backend',
|
||||
'libs': win32_extra_libs,
|
||||
}]
|
||||
|
||||
built_features += [
|
||||
{
|
||||
'name': 'cairo-win32',
|
||||
'description': 'Microsoft Windows surface backend',
|
||||
'deps': win32_extra_deps,
|
||||
},
|
||||
{
|
||||
'name': 'cairo-win32-font',
|
||||
'description': 'Microsoft Windows font backend',
|
||||
'deps': win32_extra_deps,
|
||||
}
|
||||
]
|
||||
endif
|
||||
|
||||
# FIXME: Doesn't build since at least 2011
|
||||
|
|
@ -422,7 +420,7 @@ if libudev_dep.found() and libdrm_dep.found() and false
|
|||
built_features += [{
|
||||
'name': 'cairo-drm',
|
||||
'description': 'DRM surface backend',
|
||||
'requires': 'libudev @0@ libdrm @1@'.format(libudev_required_version, libdrm_required_version),
|
||||
'deps': [libudev_dep, libdrm_dep],
|
||||
}]
|
||||
endif
|
||||
|
||||
|
|
@ -432,61 +430,42 @@ endif
|
|||
|
||||
# GL / GLESV2 / GLESV3 are mutually exclusive
|
||||
gl_backend = get_option('gl-backend')
|
||||
use_gl = false
|
||||
need_egl_functions = false
|
||||
need_wgl_functions = false
|
||||
need_glx_functions = false
|
||||
|
||||
if gl_backend in ['auto', 'gl']
|
||||
gl_dep = dependency('gl', required: gl_backend == 'gl')
|
||||
gl_dep = dependency('gl', required: false)
|
||||
if not gl_dep.found()
|
||||
if cc.has_header('GL/gl.h')
|
||||
gl_extra_libs = ['-lGL']
|
||||
gl_requires = ''
|
||||
extra_link_args += gl_extra_libs
|
||||
use_gl = true
|
||||
endif
|
||||
elif cc.has_header('GL/gl.h', dependencies: gl_dep) and cc.has_header('GL/glext.h', dependencies: gl_dep)
|
||||
use_gl = true
|
||||
gl_extra_libs = []
|
||||
gl_requires = 'gl'
|
||||
deps += [gl_dep]
|
||||
gl_dep = cc.find_library('GL', required: gl_backend == 'gl')
|
||||
endif
|
||||
endif
|
||||
if gl_dep.found() and \
|
||||
cc.has_header('GL/gl.h', required: gl_backend == 'gl', dependencies: gl_dep) and \
|
||||
cc.has_header('GL/glext.h', required: gl_backend == 'gl', dependencies: gl_dep)
|
||||
deps += [gl_dep]
|
||||
|
||||
need_egl_functions = true
|
||||
need_wgl_functions = true
|
||||
need_glx_functions = true
|
||||
|
||||
if use_gl
|
||||
need_egl_functions = true
|
||||
need_wgl_functions = true
|
||||
need_glx_functions = true
|
||||
|
||||
feature_conf.set('CAIRO_HAS_GL_SURFACE', 1)
|
||||
built_features += [{
|
||||
'name': 'cairo-gl',
|
||||
'description': 'OpenGL surface backend',
|
||||
'requires': gl_requires,
|
||||
'libs': gl_extra_libs,
|
||||
}]
|
||||
feature_conf.set('CAIRO_HAS_GL_SURFACE', 1)
|
||||
built_features += [{
|
||||
'name': 'cairo-gl',
|
||||
'description': 'OpenGL surface backend',
|
||||
'deps': [gl_dep],
|
||||
}]
|
||||
endif
|
||||
endif
|
||||
|
||||
if feature_conf.get('CAIRO_HAS_GL_SURFACE', 0) == 0 and ['auto', 'glesv2'].contains(gl_backend)
|
||||
use_glesv2 = false
|
||||
glesv2_dep = dependency('glesv2', required: gl_backend == 'glesv2')
|
||||
glesv2_dep = dependency('glesv2', required: false)
|
||||
if not glesv2_dep.found()
|
||||
if cc.has_header('GLES2/gl2.h')
|
||||
use_glesv2 = true
|
||||
glesv2_extra_libs = ['-lGLESv2']
|
||||
glesv2_requires = ''
|
||||
extra_link_args += glesv2_extra_libs
|
||||
endif
|
||||
else
|
||||
glesv2_extra_libs = []
|
||||
glesv2_requires = 'glesv2'
|
||||
use_glesv2 = true
|
||||
deps += [glesv2_dep]
|
||||
glesv2_dep = cc.find_library('GLESv2', required: gl_backend == 'glesv2')
|
||||
endif
|
||||
|
||||
if use_glesv2
|
||||
if glesv2_dep.found() and \
|
||||
cc.has_header('GLES2/gl2.h', required: gl_backend == 'glesv2', dependencies: glesv2_dep) and \
|
||||
cc.has_header('GLES2/gl2ext.h', required: gl_backend == 'glesv2', dependencies: glesv2_dep)
|
||||
deps += [glesv2_dep]
|
||||
need_egl_functions = true
|
||||
|
||||
feature_conf.set('CAIRO_HAS_GLESV2_SURFACE', 1)
|
||||
|
|
@ -494,30 +473,22 @@ if feature_conf.get('CAIRO_HAS_GL_SURFACE', 0) == 0 and ['auto', 'glesv2'].conta
|
|||
'name': 'cairo-glesv2',
|
||||
'source-key': 'cairo-gl',
|
||||
'description': 'OpenGLESv2 surface backend',
|
||||
'requires': glesv2_requires,
|
||||
'libs': glesv2_extra_libs,
|
||||
'deps': [glesv2_dep],
|
||||
}]
|
||||
endif
|
||||
endif
|
||||
|
||||
if feature_conf.get('CAIRO_HAS_GL_SURFACE', 0) == 0 and feature_conf.get('CAIRO_HAS_GLESV2_SURFACE', 0) == 0 and ['auto', 'glesv3'].contains(gl_backend)
|
||||
use_glesv3 = false
|
||||
# glesv3 is provided via libGLESv2.so (there is no libGLESv3, nor glesv3.pc)
|
||||
glesv3_dep = dependency('glesv2', required: gl_backend == 'glesv3')
|
||||
if cc.has_header('GLES3/gl3.h', dependencies: glesv3_dep)
|
||||
use_glesv3 = true
|
||||
if not glesv3_dep.found()
|
||||
glesv3_extra_libs = ['-lGLESv2']
|
||||
extra_link_args += glesv3_extra_libs
|
||||
glesv3_requires = ''
|
||||
else
|
||||
glesv3_extra_libs = []
|
||||
glesv3_requires = 'glesv2'
|
||||
deps += [glesv3_dep]
|
||||
endif
|
||||
glesv3_dep = dependency('glesv2', required: false)
|
||||
if not glesv3_dep.found()
|
||||
glesv3_dep = cc.find_library('GLESv2', required: gl_backend == 'glesv3')
|
||||
endif
|
||||
|
||||
if use_glesv3
|
||||
if glesv3_dep.found() and \
|
||||
cc.has_header('GLES3/gl3.h', required: gl_backend == 'glesv3', dependencies: glesv3_dep) and \
|
||||
cc.has_header('GLES3/gl3ext.h', required: gl_backend == 'glesv3', dependencies: glesv3_dep)
|
||||
deps += [glesv3_dep]
|
||||
need_egl_functions = true
|
||||
|
||||
feature_conf.set('CAIRO_HAS_GLESV3_SURFACE', 1)
|
||||
|
|
@ -525,8 +496,7 @@ if feature_conf.get('CAIRO_HAS_GL_SURFACE', 0) == 0 and feature_conf.get('CAIRO_
|
|||
'name': 'cairo-glesv3',
|
||||
'source-key': 'cairo-gl',
|
||||
'description': 'OpenGLESv3 surface backend',
|
||||
'requires': glesv3_requires,
|
||||
'libs': glesv3_extra_libs,
|
||||
'deps': [glesv3_dep],
|
||||
}]
|
||||
endif
|
||||
endif
|
||||
|
|
@ -542,7 +512,7 @@ if cogl_dep.found()
|
|||
built_features += [{
|
||||
'name': 'cairo-cogl',
|
||||
'description': 'Cogl surface backend',
|
||||
'requires': 'cogl-2.0-experimental',
|
||||
'deps': [cogl_dep],
|
||||
}]
|
||||
endif
|
||||
|
||||
|
|
@ -555,16 +525,15 @@ if directfb_dep.found()
|
|||
built_features += [{
|
||||
'name': 'cairo-directfb',
|
||||
'description': 'directfb surface backend',
|
||||
'requires': 'directfb',
|
||||
'deps': [directfb_dep],
|
||||
}]
|
||||
endif
|
||||
|
||||
# Untested
|
||||
openvg_dep = cc.find_library('OpenVG', has_headers: 'VG/openvg.h', required: get_option('openvg'))
|
||||
if openvg_dep.found()
|
||||
# can we use the dep here somehow instead?
|
||||
openvg_extra_libs = ['-lOpenVG']
|
||||
extra_link_args += openvg_extra_libs
|
||||
deps += [openvg_dep]
|
||||
|
||||
need_egl_functions = true
|
||||
need_glx_functions = true
|
||||
|
||||
|
|
@ -572,49 +541,38 @@ if openvg_dep.found()
|
|||
built_features += [{
|
||||
'name': 'cairo-vg',
|
||||
'description': 'OpenVG surface backend',
|
||||
'libs': openvg_extra_libs,
|
||||
'deps': [openvg_dep],
|
||||
}]
|
||||
endif
|
||||
|
||||
if need_egl_functions
|
||||
# FIXME: automagic
|
||||
egl_extra_deps = []
|
||||
egl_dep = dependency('egl', required: false)
|
||||
use_egl = false
|
||||
egl_extra_libs = []
|
||||
egl_requires = ''
|
||||
|
||||
if not egl_dep.found()
|
||||
if cc.has_header('EGL/egl.h')
|
||||
egl_extra_deps = []
|
||||
csi_dep = cc.find_library('csi', required: false)
|
||||
if csi_dep.found() and cc.has_function('csi_stream_attachresource', dependencies: [csi_dep])
|
||||
egl_extra_deps = [csi_dep]
|
||||
egl_extra_libs = ['-lcsi']
|
||||
egl_extra_deps += csi_dep
|
||||
endif
|
||||
|
||||
foreach libname : ['EGL', 'egl13', 'egl12', 'egl11']
|
||||
dep = cc.find_library(libname, required: false)
|
||||
if dep.found() and cc.has_function('eglGetError', dependencies: [dep])
|
||||
deps += [dep] + egl_extra_deps
|
||||
egl_extra_libs += ['-l@0@'.format(libname)]
|
||||
use_egl = true
|
||||
egl_dep = dep
|
||||
break
|
||||
endif
|
||||
endforeach
|
||||
endif
|
||||
else
|
||||
use_egl = true
|
||||
egl_requires = 'egl'
|
||||
deps += [egl_dep]
|
||||
endif
|
||||
|
||||
if use_egl
|
||||
if egl_dep.found()
|
||||
deps += egl_dep
|
||||
feature_conf.set('CAIRO_HAS_EGL_FUNCTIONS', 1)
|
||||
built_features += [{
|
||||
'name': 'cairo-egl',
|
||||
'description': 'EGL functions',
|
||||
'libs': egl_extra_libs,
|
||||
'requires': egl_requires,
|
||||
'deps': [egl_dep] + egl_extra_deps,
|
||||
}]
|
||||
endif
|
||||
endif
|
||||
|
|
@ -626,7 +584,7 @@ if need_glx_functions
|
|||
built_features += [{
|
||||
'name': 'cairo-glx',
|
||||
'description': 'GLX functions',
|
||||
'libs': ['-lGL'],
|
||||
'deps': [cc.find_library('GL')],
|
||||
}]
|
||||
endif
|
||||
endif
|
||||
|
|
@ -654,12 +612,6 @@ glib_dep = dependency('glib-2.0',
|
|||
)
|
||||
if gobject_dep.found() and glib_dep.found()
|
||||
feature_conf.set('CAIRO_HAS_GOBJECT_FUNCTIONS', 1)
|
||||
built_features += [{
|
||||
'name': 'cairo-gobject',
|
||||
'description': 'gobject functions',
|
||||
'requires': 'gobject-2.0 glib-2.0 @0@'.format(glib_required_version),
|
||||
'libs': ['-lcairo-gobject'],
|
||||
}]
|
||||
endif
|
||||
|
||||
if zlib_dep.found()
|
||||
|
|
@ -667,7 +619,7 @@ if zlib_dep.found()
|
|||
built_features += [{
|
||||
'name': 'cairo-script',
|
||||
'description': 'script surface backend',
|
||||
'requires': 'zlib',
|
||||
'deps': [zlib_dep],
|
||||
}]
|
||||
endif
|
||||
|
||||
|
|
@ -676,7 +628,7 @@ if zlib_dep.found()
|
|||
built_features += [{
|
||||
'name': 'cairo-ps',
|
||||
'description': 'PostScript surface backend',
|
||||
'requires': 'zlib',
|
||||
'deps': [zlib_dep],
|
||||
}]
|
||||
endif
|
||||
|
||||
|
|
@ -685,7 +637,7 @@ if zlib_dep.found()
|
|||
built_features += [{
|
||||
'name': 'cairo-pdf',
|
||||
'description': 'PDF surface backend',
|
||||
'requires': 'zlib',
|
||||
'deps': [zlib_dep],
|
||||
}]
|
||||
endif
|
||||
|
||||
|
|
@ -699,7 +651,7 @@ if zlib_dep.found() and png_dep.found()
|
|||
built_features += [{
|
||||
'name': 'cairo-xml',
|
||||
'description': 'XML surface backend',
|
||||
'requires': 'zlib',
|
||||
'deps': [zlib_dep],
|
||||
}]
|
||||
endif
|
||||
|
||||
|
|
@ -911,25 +863,17 @@ endif
|
|||
configure_file(output: 'config.h', configuration: conf)
|
||||
|
||||
foreach feature: built_features
|
||||
fconf = configuration_data()
|
||||
fconf.set('prefix', get_option('prefix'))
|
||||
fconf.set('exec_prefix', '${prefix}')
|
||||
fconf.set('libdir', '${exec_prefix}/@0@'.format(get_option('libdir')))
|
||||
fconf.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
|
||||
fconf.set('FEATURE_PC', feature['name'])
|
||||
fconf.set('FEATURE_NAME', feature['description'])
|
||||
fconf.set('VERSION', meson.project_version())
|
||||
fconf.set('FEATURE_BASE', meson.project_name())
|
||||
fconf.set('FEATURE_REQUIRES', feature.get('requires', ''))
|
||||
fconf.set('FEATURE_NONPKGCONFIG_LIBS', ' '.join(feature.get('libs', [])))
|
||||
fconf.set('FEATURE_NONPKGCONFIG_EXTRA_LIBS', '')
|
||||
fconf.set('FEATURE_NONPKGCONFIG_CFLAGS', '')
|
||||
|
||||
configure_file(input: 'src/cairo-features.pc.in',
|
||||
output: '@0@.pc'.format(feature['name']),
|
||||
configuration: fconf,
|
||||
install: true,
|
||||
install_dir: join_paths(get_option('prefix'), get_option('libdir'), 'pkgconfig')
|
||||
feature_deps = feature.get('deps', [])
|
||||
feature_libs = feature.get('libs', [])
|
||||
pkgmod.generate(libraries: [libcairo] + feature_deps + feature_libs,
|
||||
name: feature['name'],
|
||||
description: feature['description'] + ' for cairo graphics library',
|
||||
)
|
||||
meson.override_dependency(feature['name'],
|
||||
declare_dependency(link_with: libcairo,
|
||||
dependencies: feature_deps,
|
||||
link_args: feature_libs,
|
||||
)
|
||||
)
|
||||
endforeach
|
||||
|
||||
|
|
|
|||
|
|
@ -307,15 +307,13 @@ libcairo = library('cairo', cairo_sources,
|
|||
|
||||
cairo_headers += [configure_file(output: 'cairo-features.h', configuration: feature_conf)]
|
||||
|
||||
libcairo_dep = declare_dependency(link_with: libcairo,
|
||||
include_directories: incbase)
|
||||
libcairo_dep = declare_dependency(link_with: libcairo, include_directories: incsrc)
|
||||
|
||||
pkgmod.generate(libcairo,
|
||||
description: 'Multi-platform 2D graphics library',
|
||||
subdirs: [meson.project_name()],
|
||||
version: meson.project_version(),
|
||||
)
|
||||
|
||||
install_headers(cairo_headers, subdir: 'cairo')
|
||||
meson.override_dependency('cairo', libcairo_dep)
|
||||
|
||||
libcairo_dep = declare_dependency(link_with: libcairo, include_directories: incsrc)
|
||||
install_headers(cairo_headers, subdir: 'cairo')
|
||||
|
|
|
|||
|
|
@ -22,4 +22,12 @@ incgobject = include_directories('.')
|
|||
libcairogobject_dep = declare_dependency(link_with: libcairogobject,
|
||||
include_directories: [incbase, incgobject])
|
||||
|
||||
pkgmod.generate(libcairogobject,
|
||||
libraries: [libcairo, glib_dep, gobject_dep],
|
||||
description: 'cairo-gobject for cairo graphics library',
|
||||
subdirs: [meson.project_name()],
|
||||
)
|
||||
|
||||
meson.override_dependency('cairo-gobject', libcairogobject_dep)
|
||||
|
||||
install_headers(cairo_gobject_headers, subdir: 'cairo')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue