summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore26
-rw-r--r--MSVC_NMake/cairomm/meson.build17
-rw-r--r--MSVC_NMake/gendef/meson.build9
-rw-r--r--Makefile.am14
-rw-r--r--cairomm/meson.build131
-rw-r--r--cairommconfig.h.meson21
-rw-r--r--data/meson.build59
-rw-r--r--docs/reference/meson.build125
-rw-r--r--examples/meson.build33
-rw-r--r--meson.build305
-rw-r--r--meson_options.txt18
-rw-r--r--tests/meson.build47
-rw-r--r--untracked/README32
13 files changed, 817 insertions, 20 deletions
diff --git a/.gitignore b/.gitignore
index f1e82e0..f911a76 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,19 +4,7 @@ Makefile
Makefile.in
/aclocal.m4
/autom4te.cache/
-/data/cairomm-1.0.pc
-/data/cairomm-ft-1.0.pc
-/data/cairomm-pdf-1.0.pc
-/data/cairomm-png-1.0.pc
-/data/cairomm-ps-1.0.pc
-/data/cairomm-svg-1.0.pc
-/data/cairomm-xlib-1.0.pc
-/data/cairomm-xlib-xrender-1.0.pc
-/data/cairomm-win32-1.0.pc
-/data/cairomm-win32-font-1.0.pc
-/data/cairomm-quartz-1.0.pc
-/data/cairomm-quartz-font-1.0.pc
-/data/cairomm-quartz-image-1.0.pc
+/data/cairomm-*.pc
.deps/
.dirstamp
.libs/
@@ -28,16 +16,10 @@ stamp-h?
/cairommconfig.h
/cairomm-*.tar.*
-/MSVC_Net2005/cairomm/cairomm.rc
-/MSVC_Net2005/cairomm/cairommconfig.h
-/MSVC_Net2008/cairomm/cairomm.rc
-/MSVC_Net2008/cairomm/cairommconfig.h
-/MSVC_Net2010/cairomm/cairomm.rc
-/MSVC_Net2010/cairomm/cairommconfig.h
-
/docs/doc-install.pl
/docs/doc-postprocess.pl
/docs/doxygen.css
+/docs/doxygen-extra.css
/docs/tagfile-to-devhelp2.xsl
/docs/reference/Doxyfile
@@ -101,3 +83,7 @@ user-font.png
*.suo
Debug
Release
+
+# untracked/
+untracked/build_scripts/
+untracked/docs/
diff --git a/MSVC_NMake/cairomm/meson.build b/MSVC_NMake/cairomm/meson.build
new file mode 100644
index 0000000..f39be54
--- /dev/null
+++ b/MSVC_NMake/cairomm/meson.build
@@ -0,0 +1,17 @@
+# MSVC_NMake/cairomm
+
+# Input: mm_conf_data, cairommconfig_h
+# Output: cairomm_rc
+
+cairomm_rc = configure_file(
+ input: 'cairomm.rc.in',
+ output: '@BASENAME@',
+ configuration: mm_conf_data,
+)
+
+# Copy the generated configuration header into the MSVC project directory.
+configure_file(
+ input: cairommconfig_h,
+ output: 'cairommconfig.h',
+ copy: true,
+)
diff --git a/MSVC_NMake/gendef/meson.build b/MSVC_NMake/gendef/meson.build
new file mode 100644
index 0000000..3dc9cc2
--- /dev/null
+++ b/MSVC_NMake/gendef/meson.build
@@ -0,0 +1,9 @@
+# MSVC_NMake/gendef
+
+# Input: is_msvc
+# Output: gendef
+
+# Used to generate the .def file required to obtain the import .lib file
+if is_msvc
+ gendef = executable('gendef', 'gendef.cc', install: false)
+endif
diff --git a/Makefile.am b/Makefile.am
index ff0de26..0f50ed5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -40,6 +40,20 @@ dist_noinst_SCRIPTS = autogen.sh
DISTCLEANFILES = MSVC_NMake/cairomm/cairommconfig.h
+# Distribute files needed when building cairomm with Meson.
+EXTRA_DIST = \
+ meson.build \
+ meson_options.txt \
+ cairommconfig.h.meson \
+ MSVC_NMake/cairomm/meson.build \
+ MSVC_NMake/gendef/meson.build \
+ cairomm/meson.build \
+ data/meson.build \
+ docs/reference/meson.build \
+ examples/meson.build \
+ tests/meson.build \
+ untracked/README
+
# Optional: auto-generate the ChangeLog file from the git log on make dist
include $(top_srcdir)/build/dist-changelog.am
diff --git a/cairomm/meson.build b/cairomm/meson.build
new file mode 100644
index 0000000..298c930
--- /dev/null
+++ b/cairomm/meson.build
@@ -0,0 +1,131 @@
+# cairomm
+
+# Input: cairomm_build_dep, cairomm_pcname, cairomm_libversion, cairomm_rc,
+# is_msvc, gendef
+# Output: source_h_files, cairomm_dep
+
+# There are no built source files in cairomm.
+
+cairomm_cc = [
+ 'context.cc',
+ 'context_surface_quartz.cc',
+ 'context_surface_win32.cc',
+ 'context_surface_xlib.cc',
+ 'device.cc',
+ 'exception.cc',
+ 'fontface.cc',
+ 'fontoptions.cc',
+ 'matrix.cc',
+ 'path.cc',
+ 'pattern.cc',
+ 'private.cc',
+ 'quartz_font.cc',
+ 'quartz_surface.cc',
+ 'region.cc',
+ 'scaledfont.cc',
+ 'script.cc',
+ 'script_surface.cc',
+ 'surface.cc',
+ 'win32_font.cc',
+ 'win32_surface.cc',
+ 'xlib_surface.cc',
+]
+
+cairomm_public_h = [
+ 'cairomm.h',
+ 'context.h',
+ 'device.h',
+ 'enums.h',
+ 'exception.h',
+ 'fontface.h',
+ 'fontoptions.h',
+ 'matrix.h',
+ 'path.h',
+ 'pattern.h',
+ 'quartz_font.h',
+ 'quartz_surface.h',
+ 'refptr.h',
+ 'region.h',
+ 'scaledfont.h',
+ 'script.h',
+ 'script_surface.h',
+ 'surface.h',
+ 'types.h',
+ 'win32_font.h',
+ 'win32_surface.h',
+ 'xlib_surface.h',
+]
+
+cairomm_private_h = [
+ 'context_private.h',
+ 'private.h',
+]
+
+# docs/reference/meson.build needs this.
+source_h_files = cairomm_public_h
+
+install_headers(cairomm_public_h, subdir: cairomm_pcname / 'cairomm')
+
+# Make sure we are exporting the symbols from the DLL
+cairomm_cpp_args = ['-DCAIROMM_BUILD=1']
+
+# Build the .rc file for Windows builds and link to it
+extra_cairomm_objects = []
+if host_machine.system() == 'windows'
+ windows = import('windows')
+ cairomm_res = windows.compile_resources(cairomm_rc)
+ extra_cairomm_objects += cairomm_res
+endif
+
+extra_include_dirs = ['..']
+
+if not is_msvc
+ cairomm_library = library(cairomm_pcname,
+ cairomm_cc, extra_cairomm_objects,
+ version: cairomm_libversion,
+ include_directories: extra_include_dirs,
+ cpp_args: cairomm_cpp_args,
+ dependencies: cairomm_build_dep,
+ install: true,
+ )
+else # is_msvc
+
+ # Run gendef.exe to get the .def file needed for obtaining
+ # the .lib file for the cairomm DLL.
+ cairomm_int_lib = static_library('cairomm-int',
+ cairomm_cc,
+ include_directories: extra_include_dirs,
+ cpp_args: cairomm_cpp_args,
+ dependencies: cairomm_build_dep,
+ install: false,
+ )
+
+ cairomm_def = custom_target('cairomm.def',
+ output: 'cairomm.def',
+ depends: cairomm_int_lib,
+ command: [ gendef,
+ '@OUTPUT@',
+ '@0@-@1@.dll'.format(cairomm_pcname, cairomm_libversion.split('.')[0]),
+ cairomm_int_lib.full_path(),
+ ],
+ install: false,
+ )
+ cairomm_extra_link_args = ['/def:@0@'.format(cairomm_def.full_path())]
+
+ cairomm_library = library(cairomm_pcname, extra_cairomm_objects,
+ objects: cairomm_int_lib.extract_all_objects(),
+ version: cairomm_libversion,
+ dependencies: cairomm_build_dep,
+ link_depends: cairomm_def,
+ link_args: cairomm_extra_link_args,
+ install: true,
+ )
+endif
+
+# This is useful in the main project when cairomm is used as a subproject.
+# It's also used when building example programs and test programs.
+cairomm_dep = declare_dependency(
+ link_with: cairomm_library,
+ include_directories: extra_include_dirs,
+ dependencies: cairomm_build_dep
+)
diff --git a/cairommconfig.h.meson b/cairommconfig.h.meson
new file mode 100644
index 0000000..8923c96
--- /dev/null
+++ b/cairommconfig.h.meson
@@ -0,0 +1,21 @@
+#ifndef _CAIROMM_CONFIG_H
+#define _CAIROMM_CONFIG_H
+
+/* This file is part of cairomm. */
+
+/* Define to omit deprecated API from the library. */
+#mesondefine CAIROMM_DISABLE_DEPRECATED
+
+/* Defined when the -Dbuild-exceptions-api=true configure argument was given */
+#mesondefine CAIROMM_EXCEPTIONS_ENABLED
+
+/* Major version number of cairomm. */
+#mesondefine CAIROMM_MAJOR_VERSION
+
+/* Minor version number of cairomm. */
+#mesondefine CAIROMM_MINOR_VERSION
+
+/* Micro version number of cairomm. */
+#mesondefine CAIROMM_MICRO_VERSION
+
+#endif /* _CAIROMM_CONFIG_H */
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..f8e1659
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,59 @@
+# data
+
+# Input: install_prefix, install_libdir, install_datadir, install_includedir,
+# install_pkgconfigdir, cairomm_pcname, cairomm_api_version,
+# cairomm_requires, cairo_dep
+# Output: -
+
+pkg_conf_data = configuration_data()
+pkg_conf_data.set('prefix', install_prefix)
+pkg_conf_data.set('exec_prefix', '${prefix}')
+pkg_conf_data.set('libdir', '${exec_prefix}' / install_libdir)
+pkg_conf_data.set('datarootdir', '${prefix}' / install_datadir)
+pkg_conf_data.set('datadir', '${datarootdir}')
+pkg_conf_data.set('includedir', '${prefix}' / install_includedir)
+pkg_conf_data.set('PACKAGE_VERSION', meson.project_version())
+pkg_conf_data.set('CAIROMM_MODULE_NAME', cairomm_pcname)
+pkg_conf_data.set('CAIROMM_API_VERSION', cairomm_api_version)
+pkg_conf_data.set('CAIROMM_MODULES', cairomm_requires)
+pkg_conf_data.set('CAIROMM_EXTRA_LIBS', cairomm_extra_libs)
+
+configure_file(
+ input: cairomm_pcname + '.pc.in',
+ output: '@BASENAME@',
+ configuration: pkg_conf_data,
+ install_dir: install_pkgconfigdir,
+ install: true,
+)
+
+foreach cairomm_mod : ['ft', 'pdf', 'png', 'ps', 'quartz', 'quartz-font',
+ 'quartz-image', 'svg', 'win32', 'win32-font', 'xlib', 'xlib-xrender']
+
+ # Install the module only if there is a corresponding cairo module.
+ if cairo_dep.type_name() == 'pkgconfig'
+ do_install = dependency('cairo-' + cairomm_mod, required: false).found()
+ else
+ if cairomm_mod == 'png'
+ do_install = cpp_compiler.has_function('cairo_surface_write_to_png',
+ prefix: '#include <cairo.h>',
+ dependencies: cairo_dep)
+ elif cairomm_mod == 'quartz-font'
+ do_install = cpp_compiler.has_function('cairo_quartz_font_face_create_for_cgfont',
+ prefix: '#include <cairo-quartz.h>',
+ dependencies: cairo_dep)
+ elif cairomm_mod == 'win32-font'
+ do_install = cpp_compiler.has_function('cairo_win32_font_face_create_for_hfont',
+ prefix: '#include <cairo-win32.h>',
+ dependencies: cairo_dep)
+ else
+ do_install = cpp_compiler.has_header('cairo-@0@.h'.format(cairomm_mod))
+ endif
+ endif
+ configure_file(
+ input: 'cairomm-' + cairomm_mod + '-' + cairomm_api_version + '.pc.in',
+ output: '@BASENAME@',
+ configuration: pkg_conf_data,
+ install_dir: install_pkgconfigdir,
+ install: do_install,
+ )
+endforeach
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
new file mode 100644
index 0000000..ad74f33
--- /dev/null
+++ b/docs/reference/meson.build
@@ -0,0 +1,125 @@
+# docs/reference
+
+# Input: project_build_root, project_source_root, cairomm_pcname,
+# perl, build_documentation, source_h_files,
+# install_datadir, python3, doc_reference_py
+# Output: install_docdir, install_devhelpdir, book_name
+
+# There are no built source files in cairomm.
+
+tag_file_modules = [
+ 'mm-common-libstdc++',
+ 'sigc++-2.0',
+]
+doxygen_tagfiles = ''
+docinstall_flags = []
+foreach module : tag_file_modules
+ depmod = dependency(module, required: false)
+ if depmod.found()
+ doxytagfile = depmod.get_pkgconfig_variable('doxytagfile')
+ htmlrefpub = depmod.get_pkgconfig_variable('htmlrefpub', default: '')
+ htmlrefdir = depmod.get_pkgconfig_variable('htmlrefdir', default: '')
+ if htmlrefpub == ''
+ htmlrefpub = htmlrefdir
+ elif htmlrefdir == ''
+ htmlrefdir = htmlrefpub
+ endif
+ doxygen_tagfiles += ' "' + doxytagfile + '=' + htmlrefpub + '"'
+ if not htmlrefdir.endswith('/')
+ htmlrefdir += '/'
+ endif
+ docinstall_flags += ['-l', doxytagfile.split('/')[-1] + '@' + htmlrefdir]
+ endif
+endforeach
+
+book_name = cairomm_pcname
+book_title = meson.project_name() + ' Reference Manual'
+
+# Configuration data for Doxyfile.
+doc_conf_data = configuration_data()
+doc_conf_data.set('configure_input',
+ 'docs/reference/Doxyfile. Generated from Doxyfile.in by meson.configure_file().')
+doc_conf_data.set('PACKAGE_NAME', meson.project_name())
+doc_conf_data.set('PACKAGE_VERSION', meson.project_version())
+doc_conf_data.set('abs_top_builddir', project_build_root)
+doc_conf_data.set('abs_top_srcdir', project_source_root)
+doc_conf_data.set('CAIROMM_MODULE_NAME', book_name)
+doc_conf_data.set('DOXYGEN_TAGFILES', doxygen_tagfiles)
+doc_conf_data.set('PERL', perl.found() ? perl.path() : '')
+
+configure_file(
+ input: 'Doxyfile.in',
+ output: '@BASENAME@',
+ configuration: doc_conf_data,
+)
+
+# Installation directories relative to {prefix}.
+install_docdir = install_datadir / 'doc' / book_name
+install_reference_docdir = install_docdir / 'reference'
+install_devhelpdir = install_datadir / 'devhelp' / 'books' / book_name
+
+if not build_documentation
+ # Documentation shall not be built or installed.
+ # Return to the calling meson.build file.
+ subdir_done()
+endif
+
+# Input .h files to Doxygen.
+src_h_files = []
+foreach file : source_h_files
+ src_h_files += project_source_root / 'cairomm' / file
+endforeach
+
+doctool_dir = project_source_root / 'untracked' / 'docs' # MMDOCTOOLDIR
+doctool_dist_dir = 'untracked' / 'docs' # Relative to MESON_DIST_ROOT
+
+tag_file = custom_target('html_and_tag',
+ input: src_h_files,
+ output: book_name + '.tag',
+ command: [
+ python3, doc_reference_py, 'doxygen',
+ doctool_dir,
+ '@OUTPUT@',
+ '@INPUT@',
+ ],
+ build_by_default: build_documentation,
+ install: true,
+ install_dir: install_reference_docdir,
+)
+
+devhelp_file = custom_target('devhelp',
+ input: tag_file,
+ output: book_name + '.devhelp2',
+ command: [
+ python3, doc_reference_py, 'devhelp',
+ doctool_dir,
+ '@INPUT@',
+ '@OUTPUT@',
+ book_name,
+ book_title,
+ ],
+ build_by_default: build_documentation,
+)
+
+# Install Devhelp file and html files.
+meson.add_install_script(
+ python3.path(), doc_reference_py, 'install_doc',
+ doctool_dir,
+ devhelp_file.full_path(),
+ install_devhelpdir,
+ install_reference_docdir / 'html',
+ docinstall_flags
+)
+
+if not meson.is_subproject()
+ # Distribute built files and files copied by mm-common-get.
+ # (add_dist_script() is not allowed in a subproject)
+ meson.add_dist_script(
+ python3.path(), doc_reference_py, 'dist_doc',
+ doctool_dir,
+ doctool_dist_dir,
+ meson.current_build_dir(),
+ tag_file.full_path(),
+ devhelp_file.full_path(),
+ )
+endif
diff --git a/examples/meson.build b/examples/meson.build
new file mode 100644
index 0000000..1f60aea
--- /dev/null
+++ b/examples/meson.build
@@ -0,0 +1,33 @@
+# examples
+
+# input: cairomm_dep, build_examples
+
+examples = [
+# [[dir-name], exe-name, [sources]]
+ [['surfaces'], 'image-surface', ['image-surface.cc']],
+ [['surfaces'], 'pdf-surface', ['pdf-surface.cc']],
+ [['surfaces'], 'ps-surface', ['ps-surface.cc']],
+ [['surfaces'], 'svg-surface', ['svg-surface.cc']],
+ [['text'], 'text-rotate', ['text-rotate.cc']],
+ [['text'], 'toy-text', ['toy-text.cc']],
+ [['text'], 'user-font', ['user-font.cc']],
+]
+
+foreach ex : examples
+ dir = ''
+ foreach dir_part : ex[0]
+ dir = dir / dir_part
+ endforeach
+ ex_name = (dir / ex[1]).underscorify()
+ ex_sources = []
+ foreach src : ex[2]
+ ex_sources += dir / src
+ endforeach
+
+ executable(ex_name, ex_sources,
+ cpp_args: '-DCAIROMM_DISABLE_DEPRECATED',
+ dependencies: cairomm_dep,
+ gui_app: false,
+ build_by_default: build_examples
+ )
+endforeach
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..c786574
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,305 @@
+# This file is part of cairomm.
+
+project('cairomm', 'cpp',
+ version: '1.13.1',
+ license: 'LGPLv2+',
+ default_options: [
+ 'cpp_std=c++11',
+ ],
+ meson_version: '>= 0.50.0', # required for python3.path()
+)
+
+cairomm_api_version = '1.0'
+cairomm_pcname = meson.project_name() + '-' + cairomm_api_version
+
+cairomm_version_array = meson.project_version().split('.')
+cairomm_major_version = cairomm_version_array[0].to_int()
+cairomm_minor_version = cairomm_version_array[1].to_int()
+cairomm_micro_version = cairomm_version_array[2].to_int()
+
+# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
+# The relation between libtool's current:revison:age interface versioning
+# and the .so filename, .so.x.y.z, is
+# x = current - age
+# y = age
+# z = revision
+# If libtool_soversion is updated as described in libtool's documentation,
+# x.y.z will usually *not* be equal to meson.project_version().
+libtool_soversion = [5, 0, 4]
+cairomm_libversion = '@0@.@1@.@2@'.format(
+ libtool_soversion[0] - libtool_soversion[2],
+ libtool_soversion[2],
+ libtool_soversion[1])
+
+# Use these instead of meson.source_root() and meson.build_root() in subdirectories.
+# source_root() and build_root() are not useful, if this is a subproject.
+project_source_root = meson.current_source_dir()
+project_build_root = meson.current_build_dir()
+
+cpp_compiler = meson.get_compiler('cpp')
+is_msvc = cpp_compiler.get_id() == 'msvc'
+python3 = import('python').find_installation()
+
+python_version = python3.language_version()
+python_version_req = '>= 3.5'
+if not python_version.version_compare(python_version_req)
+ error('Requires Python @0@, found @1@.'.format(python_version_req, python_version))
+endif
+
+# Do we build from a git repository?
+# Suppose we do if and only if a '.git' directory or file exists.
+cmd_py = '''
+import os
+import sys
+sys.exit(os.path.isdir("@0@") or os.path.isfile("@0@"))
+'''.format(project_source_root / '.git')
+is_git_build = run_command(python3, '-c', cmd_py).returncode() != 0
+
+# Are we testing a dist tarball while it's being built?
+# There ought to be a better way. https://github.com/mesonbuild/meson/issues/6866
+is_dist_check = project_source_root.contains('dist-unpack') and \
+ project_build_root.contains('dist-build')
+
+# Options.
+maintainer_mode_opt = get_option('maintainer-mode')
+maintainer_mode = maintainer_mode_opt == 'true' or \
+ (maintainer_mode_opt == 'if-git-build' and is_git_build)
+if is_dist_check
+ message('Looks like a tarball is being tested. ' + \
+ 'Option "dist-warnings" is used instead of "warnings".')
+ warning_level = get_option('dist-warnings')
+else
+ warning_level = get_option('warnings')
+endif
+build_deprecated_api = get_option('build-deprecated-api')
+build_exceptions_api = get_option('build-exceptions-api')
+build_documentation_opt = get_option('build-documentation')
+build_documentation = build_documentation_opt == 'true' or \
+ (build_documentation_opt == 'if-maintainer-mode' and maintainer_mode)
+build_examples = get_option('build-examples')
+build_tests_opt = get_option('build-tests')
+
+# Installation directories are relative to {prefix}.
+install_prefix = get_option('prefix')
+install_includedir = get_option('includedir')
+install_libdir = get_option('libdir')
+install_datadir = get_option('datadir')
+install_pkgconfigdir = install_libdir / 'pkgconfig'
+
+# Dependencies.
+# cairomm_build_dep: Dependencies when building the cairomm library.
+# cairomm_dep (created in cairomm/meson.build):
+# Dependencies when using the cairomm library.
+sigcxx_req = '>= 2.6.0'
+cairo_req = '>= 1.10.0'
+
+# There are pkg-config files for sigc++ on MSVC, so just use that.
+sigcxx_dep = dependency('sigc++-2.0', version: sigcxx_req)
+cairo_dep = dependency('cairo', version: cairo_req, required: not is_msvc)
+
+# This is clearly on Windows...
+if not cairo_dep.found()
+ cairo_dep = cpp_compiler.find_library('cairo', has_headers: [ 'cairo.h', 'cairo-win32.h' ])
+endif
+
+cairomm_build_dep = [sigcxx_dep, cairo_dep]
+cairomm_requires = [
+ 'sigc++-2.0', sigcxx_req,
+]
+
+cairomm_extra_libs = ''
+if cairo_dep.type_name() == 'pkgconfig'
+ cairomm_requires += [ 'cairo', cairo_req ]
+else
+ cairomm_extra_libs = '-lcairo'
+endif
+cairomm_requires = ' '.join(cairomm_requires)
+
+if is_msvc
+ # We must have Visual Studio 2017 15.7 or later...
+ assert(cpp_compiler.version().split('.')[0].to_int() >= 19 and \
+ cpp_compiler.version().split('.')[1].to_int() >= 15,
+ 'Visual Studio 2017 15.7 or later is required')
+endif
+
+# Needed for M_PI on Visual Studio and some MinGW versions
+if host_machine.system() == 'windows'
+ add_project_arguments('-D_USE_MATH_DEFINES', language: 'cpp')
+endif
+
+# Some dependencies are required only in maintainer mode and/or
+# if documentation shall be built.
+mm_common_get = find_program('mm-common-get', required: false)
+
+if maintainer_mode and not mm_common_get.found()
+ error('Maintainer mode requires the \'mm-common-get\' command.\n' +
+ 'Use \'-Dmaintainer-mode=false\' or install the \'mm-common\' package, version 1.0.0 or higher')
+endif
+
+perl = find_program('perl', required: build_documentation)
+doxygen = find_program('doxygen', required: build_documentation)
+dot = find_program('dot', required: build_documentation) # Used by Doxygen
+xsltproc = find_program('xsltproc', required: build_documentation)
+
+# Some dependencies are required only for building the test programs.
+USE_SHARED_BOOST = get_option('boost-shared') # Use shared Boost::Test?
+
+boost_unit_test_framework_dep = dependency('boost', modules: 'unit_test_framework',
+ static: not USE_SHARED_BOOST, version: '>=1.33.1', required: false)
+
+fontconfig_dep = dependency('fontconfig', required: false)
+test_dep = [ boost_unit_test_framework_dep, fontconfig_dep]
+can_test = boost_unit_test_framework_dep.found() and \
+ (fontconfig_dep.found() or host_machine.system() == 'windows')
+build_tests = build_tests_opt == 'true' or \
+ (build_tests_opt == 'if-dependencies-found' and can_test)
+if build_tests and not can_test
+ error('Building the test programs requires Boost Test, version 1.33.1 or higher and Fontconfig.\n' + \
+ 'Install them or use -Dbuild-tests=false or -Dbuild-tests=if-dependencies-found')
+endif
+
+script_dir = project_source_root / 'untracked' / 'build_scripts'
+doc_reference_py = script_dir / 'doc-reference.py'
+dist_changelog_py = script_dir / 'dist-changelog.py'
+dist_build_scripts_py = script_dir / 'dist-build-scripts.py'
+
+if maintainer_mode
+ # Copy files to untracked/build_scripts and untracked/docs/docs.
+ run_command(mm_common_get, '--force', script_dir,
+ project_source_root / 'untracked' / 'docs')
+else
+ cmd_py = '''
+import os
+import sys
+sys.exit(os.path.isfile("@0@"))
+'''.format(doc_reference_py)
+ file_exists = run_command(python3, '-c', cmd_py).returncode() != 0
+ if not file_exists
+ warning('Missing files in untracked/. ' + \
+ 'Enable maintainer-mode if you want to build documentation or create a dist tarball.')
+ endif
+endif
+
+# Set compiler warnings.
+warning_flags = []
+if warning_level == 'min'
+ if is_msvc
+ warning_flags = ['/W3']
+ else
+ warning_flags = ['-Wall']
+ endif
+elif warning_level == 'max' or warning_level == 'fatal'
+ if is_msvc
+ warning_flags = ['/W4']
+ else
+ warning_flags = '-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wzero-as-null-pointer-constant'.split()
+ endif
+ if warning_level == 'fatal'
+ if is_msvc
+ warning_flags += ['/WX']
+ else
+ warning_flags += ['-Werror']
+ endif
+ warning_flags += ['-DSIGCXX_DISABLE_DEPRECATED']
+ endif
+endif
+
+warning_flags = cpp_compiler.get_supported_arguments(warning_flags)
+add_project_arguments(warning_flags, language: 'cpp')
+
+# MSVC: Ignore warnings that aren't really harmful, but make those
+# that should not be overlooked stand out.
+if is_msvc
+ foreach wd : ['/FImsvc_recommended_pragmas.h', '/wd4267', '/wd4530', '/utf-8']
+ disabled_warning = cpp_compiler.get_supported_arguments(wd)
+ add_project_arguments(disabled_warning, language: 'cpp')
+ endforeach
+endif
+
+# Create cairommconfig.h.
+mm_conf_data = configuration_data()
+if not build_deprecated_api
+ mm_conf_data.set('CAIROMM_DISABLE_DEPRECATED', 1)
+endif
+if build_exceptions_api
+ mm_conf_data.set('CAIROMM_EXCEPTIONS_ENABLED', 1)
+endif
+mm_conf_data.set('CAIROMM_MAJOR_VERSION', cairomm_major_version)
+mm_conf_data.set('CAIROMM_MINOR_VERSION', cairomm_minor_version)
+mm_conf_data.set('CAIROMM_MICRO_VERSION', cairomm_micro_version)
+mm_conf_data.set('VERSION', meson.project_version()) # for MSVC_NMake/cairomm/cairomm.rc
+
+install_includeconfigdir = install_libdir / cairomm_pcname / 'include'
+cairommconfig_h = configure_file(
+ input: 'cairommconfig.h.meson',
+ output: 'cairommconfig.h',
+ configuration: mm_conf_data,
+ install_dir: install_includeconfigdir,
+)
+
+subdir('MSVC_NMake/gendef')
+subdir('MSVC_NMake/cairomm')
+subdir('data')
+subdir('cairomm')
+subdir('examples')
+subdir('tests')
+subdir('docs/reference')
+
+if not meson.is_subproject()
+ # Add a ChangeLog file to the distribution directory.
+ # (add_dist_script() is not allowed in a subproject)
+ meson.add_dist_script(
+ python3.path(), dist_changelog_py,
+ project_source_root,
+ )
+ # Add build scripts to the distribution directory, and delete .gitignore
+ # files and an empty $MESON_DIST_ROOT/build/ directory.
+ meson.add_dist_script(
+ python3.path(), dist_build_scripts_py,
+ project_source_root,
+ 'untracked' / 'build_scripts',
+ )
+endif
+
+# Print a summary.
+real_maintainer_mode = ''
+if maintainer_mode_opt == 'if-git-build'
+ real_maintainer_mode = ' (@0@)'.format(maintainer_mode)
+endif
+
+real_build_documentation = ''
+if build_documentation_opt == 'if-maintainer-mode'
+ real_build_documentation = ' (@0@)'.format(build_documentation)
+endif
+
+real_build_tests = ''
+if build_tests_opt == 'if-dependencies-found'
+ real_build_tests = ' (@0@)'.format(build_tests)
+endif
+
+summary = [
+ '',
+ '------',
+ meson.project_name() + ' ' + meson.project_version(),
+ '',
+ ' Maintainer mode: @0@@1@'.format(maintainer_mode_opt, real_maintainer_mode),
+ ' Compiler warnings: @0@'.format(warning_level),
+ ' Build deprecated API: @0@'.format(build_deprecated_api),
+ 'Build HTML documentation: @0@@1@'.format(build_documentation_opt, real_build_documentation),
+ ' Build example programs: @0@'.format(build_examples),
+ ' Build test programs: @0@@1@'.format(build_tests_opt, real_build_tests),
+ ' Use shared Boost Test: @0@'.format(USE_SHARED_BOOST),
+ 'Directories:',
+ ' prefix: @0@'.format(install_prefix),
+ ' includedir: @0@'.format(install_prefix / install_includedir),
+ ' includecairommdir: @0@'.format(install_prefix / install_includedir / cairomm_pcname),
+ ' libdir: @0@'.format(install_prefix / install_libdir),
+ ' includeconfigdir: @0@'.format(install_prefix / install_includeconfigdir),
+ ' pkgconfigdir: @0@'.format(install_prefix / install_pkgconfigdir),
+ ' datadir: @0@'.format(install_prefix / install_datadir),
+ ' docdir: @0@'.format(install_prefix / install_docdir),
+ ' devhelpdir: @0@'.format(install_prefix / install_devhelpdir),
+ '------'
+]
+
+message('\n'.join(summary))
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..4ada13e
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,18 @@
+option('maintainer-mode', type: 'combo', choices: ['false', 'if-git-build', 'true'],
+ value: 'if-git-build', description: 'Let mm-common-get copy some files to untracked/')
+option('warnings', type: 'combo', choices: ['no', 'min', 'max', 'fatal'],
+ value: 'min', description: 'Compiler warning level')
+option('dist-warnings', type: 'combo', choices: ['no', 'min', 'max', 'fatal'],
+ value: 'fatal', description: 'Compiler warning level when a tarball is created')
+option('build-deprecated-api', type: 'boolean', value: true,
+ description: 'Build deprecated API and include it in the library')
+option('build-exceptions-api', type: 'boolean', value: true,
+ description: 'Build exceptions API and include it in the library')
+option('build-documentation', type: 'combo', choices: ['false', 'if-maintainer-mode', 'true'],
+ value: 'if-maintainer-mode', description: 'Build and install the documentation')
+option('build-examples', type: 'boolean', value: true,
+ description: 'Build example programs')
+option('build-tests', type: 'combo', choices: ['false', 'if-dependencies-found', 'true'],
+ value: 'if-dependencies-found', description: 'Build test programs (requires Boost Test and Fontconfig or Windows)')
+option('boost-shared', type: 'boolean',
+ value: false, description: 'Use shared version of boost')
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..530eb73
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,47 @@
+# tests
+
+# input: cairomm_dep, build_tests, can_test, test_dep, USE_SHARED_BOOST
+
+cairomm_tests_extra_cppargs = []
+if USE_SHARED_BOOST
+ cairomm_tests_extra_cppargs += ['-DBOOST_ALL_DYN_LINK']
+endif
+
+test_programs = [
+# [[dir-name], exe-name, [sources], [cpp-flags]]
+ [[], 'test-context', ['test-context.cc'], []],
+ [[], 'test-font-face', ['test-font-face.cc'], []],
+ [[], 'test-font-options', ['test-font-options.cc'], []],
+ [[], 'test-matrix', ['test-matrix.cc'], []],
+ [[], 'test-scaled-font', ['test-scaled-font.cc'], []],
+ [[], 'test-surface', ['test-surface.cc'],
+ ['-DPNG_STREAM_FILE="' + meson.current_source_dir() / 'png-stream-test.png"']],
+ [[], 'test-user-font', ['test-user-font.cc'], []],
+]
+
+if can_test
+ foreach ex : test_programs
+ dir = ''
+ foreach dir_part : ex[0]
+ dir = dir / dir_part
+ endforeach
+ ex_name = (dir / ex[1]).underscorify()
+ ex_sources = []
+ foreach src : ex[2]
+ ex_sources += dir / src
+ endforeach
+
+ boost_test_modname_flag = [ '-DBOOST_TEST_MODULE=@0@'.format(ex[1]) ]
+ exe_file = executable(ex_name, ex_sources,
+ cpp_args: ex[3] + boost_test_modname_flag + cairomm_tests_extra_cppargs,
+ dependencies: [cairomm_dep, test_dep],
+ gui_app: false,
+ build_by_default: build_tests,
+ )
+
+ # If exe_file is a test program, it is built by default unconditionally.
+ if build_tests
+ test(ex_name, exe_file)
+ endif
+ endforeach
+endif
diff --git a/untracked/README b/untracked/README
new file mode 100644
index 0000000..b6d2cc7
--- /dev/null
+++ b/untracked/README
@@ -0,0 +1,32 @@
+untracked/README
+
+This directory contains files not tracked by a source code control program,
+such as git. (This README file is the exception.)
+
+The files can have one of two origins.
+
+1. Copied by the mm-common-get command.
+2. Generated when cairomm is built.
+
+Files of type 2 exist here only if cairomm is built with maintainer-mode=false,
+or the directory comes from a tarball.
+Files of both types exist here only if cairomm is built with Meson,
+or the tarball is created with Meson.
+
+1. Files copied by mm-common-get
+--------------------------------
+untracked/docs/doc-install.pl
+ doc-postprocess.pl
+ doxygen-extra.css
+ tagfile-to-devhelp2.xsl
+untracked/build_scripts/dist-build-scripts.py
+ dist-changelog.py
+ doc-reference.py
+
+mm-common-get may copy more files, but they are not used by cairomm.
+
+2. Generated files
+------------------
+untracked/docs/reference/cairomm-1.0.devhelp2
+ cairomm-1.0.tag
+ html/*