build: initial support for meson build
[adg.git] / meson.build
blob2a310480d64e57852f2f6c5761e2cf7bcd137463
1 project('adg', 'c', version: '0.9.3', license: 'LGPL-2.1-or-later')
2 metadata = {
3     'api':      '1.0',
4     'homepage': 'http://adg.entidi.com/',
5     'tracker':  'https://track.entidi.com/project/view/2/',
9 # How to handle LT versions (current:revision:age):
10 # - If the library source code has changed at all since the last
11 #   update, then increment revision (‘c:r:a’ becomes ‘c:r+1:a’).
12 # - If any interfaces have been added, removed, or changed since the
13 #   last update, increment current, and set revision to 0.
14 # - If any interfaces have been added since the last public release,
15 #   then increment age.
16 # - If any interfaces have been removed or changed since the last
17 #   public release, then set age to 0.
18 cpml_current  = 4
19 cpml_revision = 2
20 cpml_age      = 0
21 adg_current  = 8
22 adg_revision = 1
23 adg_age      = 1
26 cc          = meson.get_compiler('c')
27 gnome       = import('gnome')
28 i18n        = import('i18n')
29 pkgconfig   = import('pkgconfig')
30 pkgdir      = meson.project_name() + '-' + metadata['api']
31 prefix      = get_option('prefix')
32 datadir     = join_paths(prefix, get_option('datadir'))
33 pkgdatadir  = join_paths(datadir, pkgdir)
34 localedir   = join_paths(prefix, get_option('localedir'))
35 includedir  = join_paths(prefix, get_option('includedir'), pkgdir)
38 m_dep = cc.find_library('m', required: false)
40 # G_ADD_PRIVATE macro required
41 gobject_dep = dependency('gobject-2.0', version: '>=2.38.0')
43 # cairo_scaled_font_text_to_glyphs() API required
44 cairo_dep = dependency('cairo', version: '>=1.7.4')
46 # Any release
47 cairogobject_dep = dependency('cairo-gobject')
49 # Cairo support in Pango required
50 pangocairo_dep = dependency('pangocairo', version: '>=1.10.0',
51                             required: get_option('pango'))
53 # Lookup which GTK package to use
54 gtk = get_option('gtk')
55 if gtk == 'no'
56     gtk_dep = []
57 else
58     if gtk != 'gtk2'
59         # First stable release
60         gtk_dep = dependency('gtk+-3.0', version: '>= 3.0.0',
61                              required: gtk == 'gtk3')
62     endif
63     use_gtk2 = gtk == 'gtk2' or not gtk_dep.found()
64     if use_gtk2
65         # gtk_widget_get_allocation() API required
66         gtk_dep = dependency('gtk+-2.0', version: '>=2.18.0')
67     endif
68 endif
70 # Both "check" and "yes" mean gladeui autodetection,
71 # but "yes" will fail if gladeui is not found
72 catalogdir = get_option('catalogdir')
73 if catalogdir == 'yes' or catalogdir == 'check'
74     glade_dep = dependency('gladeui-2.0', required: false)
75     if not glade_dep.found()
76         glade_dep = dependency('gladeui-1.0', required: catalogdir == 'yes')
77     endif
78     catalogdir = glade_dep.get_pkgconfig_variable('catalogdir')
79 elif catalogdir == 'no'
80     # Both 'no' and '' mean "Do not install catalogs"
81     catalogdir = ''
82 endif
84 # Support for introspection annotations required
85 gtkdoc_dep = dependency('gtk-doc', required: get_option('gtk-doc'),
86                         version: '>=1.12')
88 # First stable release
89 introspection_dep = dependency('gobject-introspection-1.0', version: '>=1.0.0',
90                                required: get_option('introspection'))
92 # Check if GLib supports the testing framework
93 testing = dependency('glib-2.0', version: '>=2.16.0',
94                      required: get_option('tests'))
97 subdir('src')
98 subdir('po')
99 if gtk_dep.found()
100     subdir('demo')
101 endif
102 if gtkdoc_dep.found()
103     subdir('docs/cpml')
104     subdir('docs/adg')
105 endif
108 summary({
109     'CPML library to use':
110         'internal (cpml-@0@ @1@)'.format(metadata['api'], meson.project_version()),
111     'Use pango for text':
112         pangocairo_dep.found() ?
113             'yes (@0@ @1@)'.format(pangocairo_dep.name(), pangocairo_dep.version()) :
114             'no (use cairo toy API)',
115     'GTK support':
116         gtk_dep.found() ?
117             'yes (@0@ @1@)'.format(gtk_dep.name(), gtk_dep.version()) :
118             'no',
119     'Install glade catalogs':
120         catalogdir == '' ? 'no' : 'yes (@0@)'.format(catalogdir),
121     'Build API reference':
122         gtkdoc_dep.found() ?
123             'yes (@0@ @1@)'.format(gtkdoc_dep.name(), gtkdoc_dep.version()) :
124             'no',
125     'GObject instrospection':
126         introspection_dep.found() ?
127             'yes (@0@ @1@)'.format(introspection_dep.name(), introspection_dep.version()) :
128             'no',
129     'Test framework support':
130         testing.found() ? 'yes' : 'no'