1generated_files = []
2version = '1.0.0'
3gir_version = '1.0'
4
5headers = [
6  'portal.h',
7  'portal-helpers.h',
8  'account.h',
9  'background.h',
10  'camera.h',
11  'email.h',
12  'filechooser.h',
13  'inhibit.h',
14  'location.h',
15  'notification.h',
16  'openuri.h',
17  'parent.h',
18  'print.h',
19  'remote.h',
20  'screenshot.h',
21  'spawn.h',
22  'trash.h',
23  'types.h',
24  'updates.h',
25  'wallpaper.h',
26]
27
28portal_enums = gnome.mkenums('portal-enums',
29  sources: headers,
30  c_template: 'portal-enums.c.template',
31  h_template: 'portal-enums.h.template',
32  install_dir: join_paths (get_option('includedir'), 'libportal'),
33  install_header: true,
34)
35generated_files += portal_enums
36
37src = [
38  'account.c',
39  'background.c',
40  'camera.c',
41  'email.c',
42  'filechooser.c',
43  'inhibit.c',
44  'location.c',
45  'notification.c',
46  'openuri.c',
47  'parent.c',
48  'portal.c',
49  'print.c',
50  'remote.c',
51  'screenshot.c',
52  'session.c',
53  'spawn.c',
54  'trash.c',
55  'updates.c',
56  'wallpaper.c',
57  generated_files,
58]
59
60gio_dep = dependency('gio-2.0', version: '>= 2.58')
61gio_unix_dep = dependency('gio-unix-2.0')
62
63install_headers(headers, subdir: 'libportal')
64
65libportal = library('portal',
66  src,
67  version: version,
68  include_directories: [top_inc, libportal_inc],
69  install: true,
70  dependencies: [gio_dep, gio_unix_dep],
71  gnu_symbol_visibility: 'hidden',
72)
73
74pkgconfig.generate(libportal,
75  description: 'Portal API wrappers',
76  name: 'libportal',
77  requires: [ gio_dep ],
78)
79
80libportal_dep = declare_dependency(
81  sources: generated_files,
82  include_directories: top_inc,
83  dependencies: [gio_dep, gio_unix_dep],
84  link_with: libportal,
85)
86
87if introspection
88  libportal_gir = gnome.generate_gir(libportal,
89    sources: generated_files + headers + src,
90    nsversion: gir_version,
91    namespace: 'Xdp',
92    symbol_prefix: 'xdp',
93    identifier_prefix: 'Xdp',
94    header: 'libportal/portal.h',
95    link_with: libportal,
96    includes: ['Gio-2.0'],
97    install: true,
98    export_packages: ['libportal'],
99   )
100  if vapi
101    libportal_vapi = gnome.generate_vapi(
102      'libportal',
103      sources: [libportal_gir[0]],
104      packages: [ 'gio-2.0' ],
105      install: true,
106    )
107  endif
108endif
109
110########
111# GTK3 #
112########
113
114if 'gtk3' in backends
115  gtk3_dep = dependency('gtk+-3.0')
116  gtk3_headers = ['portal-gtk3.h']
117  gtk3_sources = ['portal-gtk3.c']
118
119  install_headers(gtk3_headers, subdir: 'libportal-gtk3')
120
121  libportal_gtk3 = library('portal-gtk3',
122    gtk3_sources,
123    version: version,
124    include_directories: [top_inc, libportal_inc],
125    install: true,
126    dependencies: [libportal_dep, gtk3_dep],
127    gnu_symbol_visibility: 'hidden',
128  )
129
130  pkgconfig.generate(libportal_gtk3,
131    description: 'Portal API wrappers (GTK3)',
132    name: 'libportal-gtk3',
133    requires: [gtk3_dep, libportal],
134  )
135
136  libportal_gtk3_dep = declare_dependency(
137    dependencies: [libportal_dep, gtk3_dep],
138    link_with: libportal_gtk3,
139  )
140
141  if introspection
142    libportal_gtk3_gir = gnome.generate_gir(libportal_gtk3,
143      sources: gtk3_sources + gtk3_headers,
144      nsversion: gir_version,
145      namespace: 'XdpGtk3',
146      symbol_prefix: 'xdp',
147      identifier_prefix: 'Xdp',
148      header: 'libportal-gtk3/portal-gtk3.h',
149      link_with: [libportal_gtk3],
150      includes: [libportal_gir[0], 'Gtk-3.0'],
151      install: true,
152      export_packages: ['libportal-gtk3'],
153     )
154
155    if vapi
156      libportal_gtk3_vapi = gnome.generate_vapi('libportal-gtk3',
157        sources: libportal_gtk3_gir[0],
158        packages: ['gio-2.0', 'gtk+-3.0', 'libportal'],
159        gir_dirs: [meson.current_build_dir()],
160        vapi_dirs: [meson.current_build_dir()],
161        install: true,
162      )
163    endif
164  endif
165endif
166
167########
168# GTK4 #
169########
170
171if 'gtk4' in backends
172  gtk4_dep = dependency('gtk4')
173  gtk4_headers = ['portal-gtk4.h']
174  gtk4_sources = ['portal-gtk4.c']
175
176  install_headers(gtk4_headers, subdir: 'libportal-gtk4')
177
178  libportal_gtk4 = library('portal-gtk4',
179    gtk4_sources,
180    version: version,
181    include_directories: [top_inc, libportal_inc],
182    install: true,
183    dependencies: [libportal_dep, gtk4_dep],
184    gnu_symbol_visibility: 'hidden',
185  )
186
187  pkgconfig.generate(libportal_gtk4,
188    description: 'Portal API wrappers (GTK4)',
189    name: 'libportal-gtk4',
190    requires: [gtk4_dep, libportal],
191  )
192
193  libportal_gtk4_dep = declare_dependency(
194    dependencies: [libportal_dep, gtk4_dep],
195    link_with: libportal_gtk4,
196  )
197
198  if introspection
199    libportal_gtk4_gir = gnome.generate_gir(
200      libportal_gtk4,
201      sources: gtk4_sources + gtk4_headers,
202      nsversion: gir_version,
203      namespace: 'XdpGtk4',
204      symbol_prefix: 'xdp',
205      identifier_prefix: 'Xdp',
206      header: 'libportal-gtk4/portal-gtk4.h',
207      link_with: [libportal_gtk4],
208      includes: [libportal_gir[0], 'Gtk-4.0'],
209      install: true,
210      export_packages: ['libportal-gtk4'],
211     )
212
213    if vapi
214      libportal_gtk4_vapi = gnome.generate_vapi('libportal-gtk4',
215        sources: libportal_gtk4_gir[0],
216        packages: ['gio-2.0', 'gtk4', 'libportal'],
217        gir_dirs: [meson.current_build_dir()],
218        vapi_dirs: [meson.current_build_dir()],
219        install: true,
220      )
221    endif
222  endif
223endif
224
225########
226# Qt 5 #
227########
228
229if 'qt5' in backends
230  add_languages('cpp', required : true)
231
232  qt5_dep = dependency('qt5', modules: ['Core', 'Gui', 'X11Extras', 'Widgets'])
233  qt5_headers = ['portal-qt5.h']
234  qt5_sources = ['portal-qt5.cpp']
235
236  install_headers(qt5_headers, subdir: 'libportal-qt5')
237
238  libportal_qt5 = library('portal-qt5',
239    qt5_sources,
240    version: version,
241    include_directories: [top_inc, libportal_inc],
242    cpp_args : '-std=c++11',
243    install: true,
244    dependencies: [libportal_dep, qt5_dep],
245    gnu_symbol_visibility: 'hidden',
246  )
247
248  pkgconfig.generate(libportal_qt5,
249    description: 'Portal API wrappers (Qt 5)',
250    name: 'libportal-qt5',
251    requires: [qt5_dep, libportal],
252  )
253
254  libportal_qt5_dep = declare_dependency(
255    dependencies: [libportal_dep, qt5_dep],
256    link_with: libportal_qt5,
257  )
258endif
259