summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2017-05-23 17:13:18 +0100
committerSam Thursfield <sam@afuera.me.uk>2017-07-21 14:08:09 +0100
commit27eb553237d54a94736d7f815fd475d650a9cdda (patch)
tree0b0ee872c5982e77b75bf9166bfab3577d13b53d
parentc5dbd3315626721779cf93efb52fbd3e32f96542 (diff)
downloadlibmediaart-meson.tar.gz
Meson build instructions for libmediaartmeson
These are hopefully complete already. I have compared an Autotools-built and a Meson-built install of libmediaart and found only the following differences: * libmediaart-2.0.la isn't generated by Meson * External references in the gtk-doc documentation are relative with Meson and absolute with Autotools * Some changes in generated .vapi file and .pc file https://bugzilla.gnome.org/show_bug.cgi?id=783562
-rw-r--r--config.h.meson.in16
-rw-r--r--docs/meson.build1
-rw-r--r--docs/reference/libmediaart/meson.build8
-rw-r--r--docs/reference/meson.build1
-rw-r--r--libmediaart/meson.build63
-rw-r--r--meson.build119
-rw-r--r--meson_options.txt2
-rw-r--r--tests/meson.build7
8 files changed, 217 insertions, 0 deletions
diff --git a/config.h.meson.in b/config.h.meson.in
new file mode 100644
index 0000000..67ee36a
--- /dev/null
+++ b/config.h.meson.in
@@ -0,0 +1,16 @@
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define if we have GdkPixbuf */
+#mesondefine HAVE_GDKPIXBUF
+
+/* Define if we have Qt */
+#mesondefine HAVE_QT
+
+/* Define if we have Qt4 */
+#mesondefine HAVE_QT4
+
+/* Define if we have Qt5 */
+#mesondefine HAVE_QT5
+
+/* defines how to decorate public symbols while building */
+#mesondefine _LIBMEDIAART_EXTERN
diff --git a/docs/meson.build b/docs/meson.build
new file mode 100644
index 0000000..ead14c4
--- /dev/null
+++ b/docs/meson.build
@@ -0,0 +1 @@
+subdir('reference')
diff --git a/docs/reference/libmediaart/meson.build b/docs/reference/libmediaart/meson.build
new file mode 100644
index 0000000..4633f0d
--- /dev/null
+++ b/docs/reference/libmediaart/meson.build
@@ -0,0 +1,8 @@
+version_xml = configure_file(input: 'version.xml.in',
+ output: 'version.xml',
+ configuration: conf)
+
+gnome.gtkdoc('libmediaart',
+ src_dir: 'libmediaart',
+ main_sgml: 'libmediaart-docs.sgml',
+ install: true)
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
new file mode 100644
index 0000000..a6130a4
--- /dev/null
+++ b/docs/reference/meson.build
@@ -0,0 +1 @@
+subdir('libmediaart')
diff --git a/libmediaart/meson.build b/libmediaart/meson.build
new file mode 100644
index 0000000..2ee6a1f
--- /dev/null
+++ b/libmediaart/meson.build
@@ -0,0 +1,63 @@
+libmediaart_public_headers = [
+ 'cache.h',
+ 'extract.h',
+ 'extractgeneric.h',
+ 'mediaart.h',
+]
+
+libmediaart_sources = [
+ 'cache.c',
+ 'extract.c',
+ 'storage.c'
+]
+
+if image_library_name == 'gdk-pixbuf-2.0'
+ libmediaart_sources += 'extractpixbuf.c'
+elif image_library_name == 'QtGui' or image_library_name == 'Qt5Gui'
+ libmediaart_sources += 'extractqt.cpp'
+else
+ libmediaart_sources += 'extractdummy.c'
+endif
+
+marshal = gnome.genmarshal('marshal',
+ sources: 'marshal.list',
+ prefix: 'media_art_marshal')
+
+libmediaart_dependencies = [glib, gio_unix, gobject, image_library]
+
+libmediaart = shared_library(
+ 'mediaart-' + libmediaart_api_version,
+ libmediaart_sources, marshal[0], marshal[1],
+ dependencies: libmediaart_dependencies,
+ c_args: libmediaart_cflags,
+ include_directories: root_inc,
+ install: true,
+)
+
+libmediaart_gir_and_typelib = gnome.generate_gir(libmediaart,
+ sources: libmediaart_sources + libmediaart_public_headers,
+ nsversion: libmediaart_api_version,
+ namespace: 'MediaArt',
+ identifier_prefix: 'MediaArt',
+ symbol_prefix: 'media_art',
+ includes: ['Gio-2.0', 'GObject-2.0'],
+ extra_args: [
+ '--c-include=libmediaart/mediaart.h',
+ '--cflags-begin'] + libmediaart_cflags + ['--cflags-end',
+ ],
+ install: true
+)
+
+libmediaart_vapi = gnome.generate_vapi('libmediaart-' + libmediaart_api_version,
+ sources: libmediaart_gir_and_typelib[0],
+ packages: 'gio-2.0',
+ install: true)
+
+libmediaart_dep = declare_dependency(
+ link_with: libmediaart,
+ dependencies: libmediaart_dependencies,
+ include_directories: root_inc,
+)
+
+install_headers(libmediaart_public_headers,
+ subdir: 'libmediaart-@0@/libmediaart'.format(libmediaart_api_version))
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..f6ebe7a
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,119 @@
+project('libmediaart', 'c', 'cpp', version: '1.9.1')
+
+gnome = import('gnome')
+
+gnome = import('gnome')
+pkgconfig = import('pkgconfig')
+
+cc = meson.get_compiler('c')
+
+# This is the X.Y used in -lliblibmediaart-FOO-X.Y
+libmediaart_api_version = '2.0'
+
+glib_required = '2.38.0'
+
+gdk_pixbuf = dependency('gdk-pixbuf-2.0', version: '> 2.12.0', required: false)
+glib = dependency('glib-2.0', version: '> ' + glib_required)
+gio = dependency('gio-2.0', version: '> ' + glib_required)
+gio_unix = dependency('gio-unix-2.0', version: '> ' + glib_required)
+gobject = dependency('gobject-2.0', version: '> ' + glib_required)
+qt4 = dependency('qt4', version: '> 4.7.1', modules: 'Gui', required: false)
+qt5 = dependency('qt5', version: '> 5.0.0', modules: 'Gui', required: false)
+
+##################################################################
+# Choose between backends (GdkPixbuf/Qt/etc)
+##################################################################
+
+image_library_name = ''
+
+if gdk_pixbuf.found()
+ if get_option('image_library') == 'auto' or get_option('image_library') == 'gdk-pixbuf'
+ image_library = gdk_pixbuf
+ image_library_name = 'gdk-pixbuf-2.0'
+ endif
+elif get_option('image_library') == 'icu'
+ error('gdk-pixbuf backend explicitly requested, but gdk-pixbuf library was not found')
+endif
+
+if image_library_name == ''
+ if qt5.found()
+ if get_option('image_library') == 'auto' or get_option('image_library') == 'qt5'
+ image_library = qt5
+ image_library_name = 'Qt5Gui'
+ endif
+ elif get_option('image_library') == 'qt5'
+ error('qt5 explicitly requested, but not found')
+ endif
+endif
+
+if image_library_name == ''
+ if qt4.found()
+ if get_option('image_library') == 'auto' or get_option('image_library') == 'qt4'
+ image_library = qt4
+ image_library_name = 'QtGui'
+ endif
+ elif get_option('image_library') == 'qt4'
+ error('qt4 explicitly requested, but not found')
+ endif
+endif
+
+if image_library_name == ''
+ error('No usable image processing backends were found.')
+endif
+
+conf = configuration_data()
+
+conf.set('HAVE_GDKPIXBUF', (image_library_name == 'gdk-pixbuf-2.0'))
+conf.set('HAVE_QT', (image_library_name == 'QtGui' or image_library_name == 'Qt5Gui'))
+conf.set('HAVE_QT4', (image_library_name == 'QtGui'))
+conf.set('HAVE_QT5', (image_library_name == 'Qt5Gui'))
+conf.set('LIBMEDIAART_VERSION', meson.project_version())
+
+libmediaart_cflags = [
+ '-DLIBMEDIAART_COMPILATION'
+]
+
+# Symbol visibility.
+if get_option('default_library') != 'static'
+ if host_machine.system() == 'windows'
+ conf.set('DLL_EXPORT', true)
+ conf.set('_LIBMEDIAART_EXTERN', '__declspec(dllexport) extern')
+ if cc.get_id() != 'msvc'
+ libmediaart_cflags += ['-fvisibility=hidden']
+ endif
+ else
+ conf.set('_LIBMEDIAART_EXTERN', '__attribute__((visibility("default"))) extern')
+ libmediaart_cflags += ['-fvisibility=hidden']
+ endif
+endif
+
+configure_file(input: 'config.h.meson.in',
+ output: 'config.h',
+ configuration: conf)
+
+root_inc = include_directories('.')
+
+subdir('libmediaart')
+subdir('docs')
+subdir('tests')
+
+pkgconfig.generate(
+ libraries: libmediaart,
+ name: 'libmediaart- ' + libmediaart_api_version,
+ version: meson.project_version(),
+ description: 'libmediaart - Media art extraction and cache management library',
+ filebase: 'libmediaart-' + libmediaart_api_version,
+ subdirs: 'libmediaart-' + libmediaart_api_version,
+ requires: 'glib-2.0',
+ requires_private: image_library_name,
+ libraries_private: ['-lz', '-lm'])
+
+summary = [
+ '\nBuild Configuration:',
+ ' Prefix: ' + get_option('prefix'),
+ ' Source code location: ' + meson.source_root(),
+ ' Compiler: ' + cc.get_id(),
+ ' Image processing library: ' + image_library_name,
+]
+
+message('\n'.join(summary))
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..9fc8221
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,2 @@
+option('image_library', type: 'combo', choices: ['auto', 'gdk-pixbuf', 'qt4', 'qt5'],
+ description: 'Which image processing backend to use')
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..28834c0
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,7 @@
+mediaart_test = executable('mediaart-test',
+ 'mediaarttest.c',
+ dependencies: libmediaart_dep,
+)
+
+test('mediaart', mediaart_test,
+ env: 'G_TEST_SRCDIR=' + meson.current_source_dir())