clang-tidy: bugprone-switch-missing-default-case
[geeqie.git] / meson.build
1 # This file is a part of Geeqie project (https://www.geeqie.org/).
2 # Copyright (C) 2008 - 2022 The Geeqie Team
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
14 # Meson default directories used in this project:
15 # prefix - /usr/local
16 # bindir - bin
17 # datadir - share
18
19 # Meson core options:
20 # buildtype
21 # debug
22
23 # Project expanded default directories:
24 # prefix        /usr/local/
25 # bindir        /usr/local/bin                          geeqie executable
26 # gq_bindir     /usr/local/lib/geeqie               *   plugins scripts
27 # datadir       /usr/local/share/
28 #               /usr/local/share/applications           org.geeqie.Geeqie.desktop
29 # [gq_]appdir   /usr/local/share/geeqie/            *   org,geeqie.template.desktop
30 # desktopdir    /usr/local/share/geeqie/applications    plugin desktop files
31 # appdatadir    /usr/local/share/metainfo               org.geeqie.Geeqie.appdata.xml
32 # icondir       /usr/local/share/pixmaps                geeqie.png icon
33 # [gq_]helpdir  /usr/local/share/doc/geeqie         *   readme files etc.
34 # [gq_]htmldir  /usr/local/share/doc/geeqie/html    *   help files
35 # gq_localedir  /usr/locale/share/locale
36 # mandir1       /usr/local/share/man/man1               man page
37 # completionsdir /usr/local/share/bash-completion/completions bash command line completions
38 # podir         project_root/po
39
40 # * See meson_options.txt file
41
42 project(
43     'geeqie',
44     'c',
45     'cpp',
46     version : run_command('./version.sh', check : true).stdout().strip(),
47     license : ['GPL-2.0-or-later'],
48     meson_version : '>=1.0.0',
49     default_options : ['cpp_std=c++14', 'warning_level=3', 'buildtype=debugoptimized', 'cpp_link_args=-rdynamic']
50 )
51
52 # To inhibit warnings from the generated file icons.h
53 add_global_arguments('-Wno-overlength-strings', language : 'c')
54
55 # To compile originally-C files as C++
56 add_global_arguments('-Wno-error=deprecated-declarations', language : 'cpp')
57
58 # Project requirements
59 project_sources = []
60 gnome = import('gnome')
61 thread_dep = dependency('threads')
62 cc = meson.get_compiler('cpp')
63 i18n = import('i18n')
64 fs = import('fs')
65 configuration_inc = include_directories('.')
66
67 # Extended stack trace using backward-app
68 option = get_option('devel')
69 if option.enabled()
70     if cc.has_link_argument('-ldwarf')
71         add_project_link_arguments('-ldwarf', language: 'cpp')
72     endif
73 endif
74
75 # External programs
76 glib_compile_resources = find_program('glib-compile-resources', required : true)
77 glib_genmarshal = find_program('glib-genmarshal', required : true)
78
79 option = get_option('git')
80 if not option.disabled()
81     running_from_git = find_program('git', required: false).found() and fs.is_dir('.git')
82 else
83     running_from_git = false
84     summary({'git' : ['disabled - ChangeLog, ChangeLog.html, lua-api help file created:', false]}, section : 'Documentation', bool_yn : true)
85 endif
86
87 debug = get_option('debug')
88
89 # Note that main.cc sets prefix to the directory above where the executable is run from.
90 # This is to allow AppImages to be used
91
92 # These gq_* variables are paths relative to /prefix/,
93 # and are also used in defines in the source as GQ_*
94 if get_option('gq_appdir') == ''
95     gq_appdir = join_paths(get_option('datadir'), 'geeqie')
96 else
97     gq_appdir = get_option('gq_appdir')
98 endif
99
100 # This is not the same as Meson bindir
101 if get_option('gq_bindir') == ''
102     gq_bindir = 'lib/geeqie'
103 else
104     gq_bindir = get_option('gq_bindir')
105 endif
106
107 if get_option('gq_helpdir') == ''
108     gq_helpdir = join_paths(get_option('datadir'), 'doc/geeqie')
109 else
110     gq_helpdir = get_option('gq_helpdir')
111 endif
112
113 if get_option('gq_htmldir') == ''
114     gq_htmldir = join_paths(get_option('datadir'), 'doc/geeqie/html')
115 else
116     gq_htmldir = get_option('gq_htmldir')
117 endif
118
119 if get_option('gq_localedir') == ''
120     gq_localedir = join_paths(get_option('datadir'), 'locale')
121 else
122     gq_localedir = get_option('gq_localedir')
123 endif
124
125
126 # Set up the absolute directory paths used
127 prefix = get_option('prefix')
128 datadir = join_paths(prefix, get_option('datadir'))
129
130 # Installation paths are absolute
131 appdir = join_paths(prefix, gq_appdir)
132 appdatadir = join_paths(datadir, 'metainfo')
133 desktopdir = join_paths(datadir, meson.project_name(), 'applications')
134 helpdir = join_paths(prefix, gq_helpdir)
135 htmldir = join_paths(prefix, gq_htmldir)
136 icondir = join_paths(datadir, 'pixmaps')
137 mandir1 = join_paths(datadir, 'man', 'man1')
138 completionsdir = join_paths(datadir, 'bash-completion', 'completions')
139 podir = join_paths(meson.project_source_root(), 'po')
140 scriptsdir = join_paths(meson.project_source_root(), 'scripts')
141
142 summary({'gq_appdir': gq_appdir,
143         'gq_bindir': gq_helpdir,
144         'gq_helpdir': gq_helpdir,
145         'gq_htmldir': gq_htmldir,
146         'gq_localedir': gq_localedir,
147         }, section: 'Directories')
148
149 # Create the define constants used in the sources. Set via config.h.in
150 conf_data = configuration_data()
151 conf_data.set('DEBUG', debug)
152
153 conf_data.set('HAVE_GTK4', 0)
154 option = get_option('gtk4')
155 if option.enabled()
156     gtk_dep = dependency('gtk4', required: true)
157     conf_data.set('HAVE_GTK4', 1)
158 else
159     gtk_dep = dependency('gtk+-3.0', version : '>=3.24', required: true)
160 endif
161 glib_dep = dependency('glib-2.0', version : '>=2.52', required: true)
162
163 # Required only when backward-cpp is used
164 conf_data.set('HAVE_DEVELOPER', 0)
165 libdw_dep = []
166 libunwind_dep = []
167 option = get_option('devel')
168 if option.enabled()
169     libdw_dep = dependency('libdw', required : true)
170     if libdw_dep.found()
171         libunwind_dep = dependency('libunwind', required : true)
172         if libunwind_dep.found()
173             conf_data.set('HAVE_DEVELOPER', 1)
174             summary({'developer mode' : ['extended stacktrace:', true]}, section : 'Debugging', bool_yn : true)
175         else
176             summary({'developer mode' : ['libunwind not found. extended stacktrace:', false]}, section : 'Debugging', bool_yn : true)
177         endif
178     else
179         summary({'developer mode' : ['libdw not found. extended stacktrace:', false]}, section : 'Debugging', bool_yn : true)
180     endif
181 else
182     summary({'developer mode' : ['extended stacktrace:', false]}, section : 'Debugging', bool_yn : true)
183 endif
184
185 # Required only for seg. fault stacktrace and backtrace debugging
186 conf_data.set('HAVE_EXECINFO_H', 0)
187 option = get_option('execinfo')
188 libexecinfo_dep = []
189 if not option.disabled()
190     result = cc.check_header('execinfo.h')
191     if result
192         # Include unconditionally dependency for NetBSD.
193         libexecinfo_dep = cc.find_library('execinfo', required : false)
194         conf_data.set('HAVE_EXECINFO_H', 1)
195         summary({'execinfo' : ['stacktrace supported:', true]}, section : 'Debugging', bool_yn : true)
196     else
197         summary({'execinfo' : ['stacktrace supported:', false]}, section : 'Debugging', bool_yn : true)
198     endif
199 else
200     summary({'execinfo' : ['stacktrace supported:', false]}, section : 'Debugging', bool_yn : true)
201 endif
202
203 conf_data.set('HAVE_ARCHIVE', 0)
204 libarchive_dep = []
205 req_version = '>=3.4.0'
206 option = get_option('archive')
207 if not option.disabled()
208     libarchive_dep = dependency('libarchive', version : req_version, required : get_option('archive'))
209     if libarchive_dep.found()
210         conf_data.set('HAVE_ARCHIVE', 1)
211         summary({'archive' : ['archive files e.g. .zip supported:', true]}, section : 'Configuration', bool_yn : true)
212     else
213         summary({'archive' : ['libarchive ' + req_version + ' not found - archive files e.g. .zip supported::', false]}, section : 'Configuration', bool_yn : true)
214     endif
215 else
216     summary({'archive' : ['disabled - archive files e.g. .zip supported:', false]}, section : 'Configuration', bool_yn : true)
217 endif
218
219 conf_data.set('HAVE_LCMS', 0)
220 conf_data.set('HAVE_LCMS2', 0)
221 lcms_dep = []
222 req_version = '>=2.0'
223 option = get_option('cms')
224 if not option.disabled()
225     xxd = find_program('xxd', 'xxdi.pl', required : false)
226     if xxd.found()
227         lcms_dep = dependency('lcms2', version : req_version, required : get_option('cms'))
228         if lcms_dep.found()
229             conf_data.set('HAVE_LCMS', 1)
230             conf_data.set('HAVE_LCMS2', 1)
231             summary({'cms' : ['color management supported:', true]}, section : 'Configuration', bool_yn : true)
232         else
233             summary({'cms' : ['lcms2' + req_version + ' not found - color management supported:', false]}, section : 'Configuration', bool_yn : true)
234         endif
235     else
236         summary({'cms' : ['xxd or xxdi.pl not found - color management supported:', false]}, section : 'Configuration', bool_yn : true)
237     endif
238 else
239     summary({'cms' : ['disabled - color management supported:', false]}, section : 'Configuration', bool_yn : true)
240 endif
241
242 conf_data.set('HAVE_DJVU', 0)
243 ddjvuapi_dep = []
244 req_version = '>=2.5.27'
245 option = get_option('djvu')
246 if not option.disabled()
247     ddjvuapi_dep = dependency('ddjvuapi', version : req_version, required : get_option('djvu'))
248     if ddjvuapi_dep.found()
249         conf_data.set('HAVE_DJVU', 1)
250         summary({'djvu' : ['djvu files supported:', true]}, section : 'Configuration', bool_yn : true)
251     else
252         summary({'djvu' : ['ddjvuapi ' + req_version + ' not found - djvu files supported:', false]}, section : 'Configuration', bool_yn : true)
253     endif
254 else
255     summary({'djvu' : ['disabled - djvu files supported:', false]}, section : 'Configuration', bool_yn : true)
256 endif
257
258 option = get_option('evince')
259 if not option.disabled()
260     evince = find_program('evince', required : false)
261     if evince.found()
262         summary({'print preview' : ['print preview supported:', true]}, section : 'Configuration', bool_yn : true)
263     else
264         summary({'print preview' : ['evince not found - print preview supported:', false]}, section : 'Configuration', bool_yn : true)
265     endif
266 else
267     summary({'print preview' : ['disabled - print preview supported:', false]}, section : 'Configuration', bool_yn : true)
268 endif
269
270 # Required only for seg. fault stacktrace and backtrace debugging
271 conf_data.set('HAVE_EXECINFO_H', 0)
272 option = get_option('execinfo')
273 if not option.disabled()
274     result = cc.check_header('execinfo.h')
275     if result
276         conf_data.set('HAVE_EXECINFO_H', 1)
277         summary({'execinfo' : ['stacktrace supported:', true]}, section : 'Configuration', bool_yn : true)
278     else
279         summary({'execinfo' : ['stacktrace supported:', false]}, section : 'Configuration', bool_yn : true)
280     endif
281 else
282     summary({'execinfo' : ['stacktrace supported:', false]}, section : 'Configuration', bool_yn : true)
283 endif
284
285 conf_data.set('HAVE_EXIV2', 0)
286 exiv2_dep = []
287 req_version = '>=0.18'
288 option = get_option('exiv2')
289 if not option.disabled()
290     exiv2_dep = dependency('exiv2', version : req_version, required : get_option('exiv2'))
291     if exiv2_dep.found()
292         conf_data.set('HAVE_EXIV2', 1)
293         summary({'exiv2' : ['image metadata processed by exiv2:', true]}, section : 'Configuration', bool_yn : true)
294     else
295         summary({'exiv2' : ['exiv2 ' + req_version + ' not found - image data not processed by exiv2:', false]}, section : 'Configuration', bool_yn : true)
296     endif
297 else
298     summary({'exiv2' : ['disabled - image data processed by exiv2:', false]}, section : 'Configuration', bool_yn : true)
299 endif
300
301 conf_data.set('HAVE_CLUTTER', 0)
302 conf_data.set('HAVE_LIBCHAMPLAIN', 0)
303 conf_data.set('HAVE_LIBCHAMPLAIN_GTK', 0)
304 champlain_dep = []
305 champlain_gtk_dep = []
306 clutter_dep = []
307 clutter_gtk_dep = []
308 req_version_champlain = '>=0.12'
309 req_version_champlain_gtk = '>=0.12'
310 req_version_clutter = '>=1.0'
311 req_version_clutter_gtk = '>=1.0'
312 option = get_option('gps-map')
313 if not option.disabled()
314     champlain_dep = dependency('champlain-0.12', version : req_version_champlain, required : get_option('gps-map'))
315     champlain_gtk_dep = dependency('champlain-gtk-0.12', version : req_version_champlain_gtk, required : get_option('gps-map'))
316     if champlain_dep.found() and champlain_gtk_dep.found()
317         clutter_dep = dependency('clutter-1.0', version : req_version_clutter, required : get_option('gps-map'))
318         clutter_gtk_dep = dependency('clutter-gtk-1.0', version : req_version_clutter_gtk, required : get_option('gps-map'))
319         if clutter_dep.found() and clutter_gtk_dep.found()
320             conf_data.set('HAVE_CLUTTER', 1)
321             conf_data.set('HAVE_LIBCHAMPLAIN', 1)
322             conf_data.set('HAVE_LIBCHAMPLAIN_GTK', 1)
323             summary({'gps-map' : ['GPS map displayed', true]}, section : 'Configuration', bool_yn : true)
324         else
325             if not clutter_dep.found()
326                 summary({'gps-map-clutter' : ['clutter-1.0 ' + req_version_clutter + ' not found - GPS map displayed:', false]}, section : 'Configuration', bool_yn : true)
327             endif
328             if not clutter_gtk_dep.found()
329                 summary({'gps-map-clutter-gtk' : ['clutter-gtk-1.0 ' + req_version_clutter_gtk + ' not found - GPS map displayed:', false]}, section : 'Configuration', bool_yn : true)
330             endif
331         endif
332     else
333         if not champlain_dep.found()
334             summary({'gps-map-champlain' : ['champlain-0.12 ' + req_version_champlain + ' not found - GPS map displayed:', false]}, section : 'Configuration', bool_yn : true)
335         endif
336         if not champlain_gtk_dep.found()
337             summary({'gps-map-champlain-gtk' : ['champlain-gtk-0.12 ' + req_version_champlain_gtk + ' not found - GPS map displayed:', false]}, section : 'Configuration', bool_yn : true)
338         endif
339     endif
340 else
341     summary({'gps-map' : ['disabled - GPS map displayed:', false]}, section : 'Configuration', bool_yn : true)
342 endif
343
344 conf_data.set('HAVE_HEIF', 0)
345 libheif_dep = []
346 req_version = '>=1.3.2'
347 option = get_option('heif')
348 if not option.disabled()
349     libheif_dep = dependency('libheif', version : req_version, required : get_option('heif'))
350     if libheif_dep.found()
351         conf_data.set('HAVE_HEIF', 1)
352         summary({'heif' : ['heif files supported:', true]}, section : 'Configuration', bool_yn : true)
353     else
354         summary({'heif' : ['libheif ' + req_version + ' not found - heif files supported:', false]}, section : 'Configuration', bool_yn : true)
355     endif
356 else
357     summary({'heif' : ['disabled - heif files supported:', false]}, section : 'Configuration', bool_yn : true)
358 endif
359
360 conf_data.set('HAVE_J2K', 0)
361 libopenjp2_dep = []
362 req_version = '>=2.3.0'
363 option = get_option('j2k')
364 if not option.disabled()
365     libopenjp2_dep = dependency('libopenjp2', version : req_version, required : get_option('j2k'))
366     if libopenjp2_dep.found()
367         conf_data.set('HAVE_J2K', 1)
368         summary({'j2k' : ['j2k files supported:', true]}, section : 'Configuration', bool_yn : true)
369     else
370         summary({'j2k' : ['libopenjp2 ' + req_version + ' not found - j2k files supported:', false]}, section : 'Configuration', bool_yn : true)
371     endif
372 else
373     summary({'j2k' : ['disabled - j2k files supported:', false]}, section : 'Configuration', bool_yn : true)
374 endif
375
376 conf_data.set('HAVE_JPEG', 0)
377 libjpeg_dep = []
378 option = get_option('jpeg')
379 if not option.disabled()
380     libjpeg_dep = dependency('libjpeg', required : get_option('jpeg'))
381     if libjpeg_dep.found()
382         if cc.has_function('jpeg_destroy_decompress', dependencies : libjpeg_dep)
383             conf_data.set('HAVE_JPEG', 1)
384             summary({'jpeg' : ['jpeg files supported:', true]}, section : 'Configuration', bool_yn : true)
385         else
386             summary({'jpeg' : ['jpeg_destroy_decompress not found - jpeg files supported:', false]}, section : 'Configuration', bool_yn : true)
387         endif
388     else
389         summary({'jpeg' : ['libjpeg: not found', false]}, section : 'Configuration', bool_yn : true)
390     endif
391 else
392     summary({'jpeg' : ['disabled - jpeg files supported:', false]}, section : 'Configuration', bool_yn : true)
393 endif
394
395 conf_data.set('HAVE_JPEGXL', 0)
396 libjxl_dep = []
397 req_version = '>=0.3.7'
398 option = get_option('jpegxl')
399 if not option.disabled()
400     libjxl_dep = dependency('libjxl', version : req_version, required : get_option('jpegxl'))
401     if libjxl_dep.found()
402         conf_data.set('HAVE_JPEGXL', 1)
403         summary({'jpegxl' : ['jpegxl files supported:', true]}, section : 'Configuration', bool_yn : true)
404     else
405         summary({'jpegxl' : ['libjxl ' + req_version + ' not found - jpegxl files supported:', false]}, section : 'Configuration', bool_yn : true)
406     endif
407 else
408     summary({'jpegxl' : ['disabled - jpegxl files supported:', false]}, section : 'Configuration', bool_yn : true)
409 endif
410
411 conf_data.set('HAVE_RAW', 0)
412 libraw_dep = []
413 req_version = '>=0.20'
414 option = get_option('libraw')
415 if not option.disabled()
416     libraw_dep = dependency('libraw', version : req_version, required : get_option('libraw'))
417     if libraw_dep.found()
418         conf_data.set('HAVE_RAW', 1)
419         summary({'libraw' : ['.cr3 files supported:', true]}, section : 'Configuration', bool_yn : true)
420     else
421         summary({'libraw' : ['libraw ' + req_version + ' not found - .cr3 files supported:', false]}, section : 'Configuration', bool_yn : true)
422     endif
423 else
424     summary({'libraw' : ['disabled - .cr3 files supported:', false]}, section : 'Configuration', bool_yn : true)
425 endif
426
427 conf_data.set('HAVE_LUA', 0)
428 lua_dep = []
429 req_version = '>=5.3'
430 option = get_option('lua')
431 if not option.disabled()
432     lua_dep = dependency('lua', 'lua5.3', 'lua-5.3', 'lua53', version: req_version, required: get_option('lua'))
433     if lua_dep.found()
434         conf_data.set('HAVE_LUA', 1)
435         summary({'lua' : ['lua supported:', true]}, section : 'Configuration', bool_yn : true)
436     else
437         summary({'lua' : ['lua ' + req_version + ' not found - lua supported:', false]}, section : 'Configuration', bool_yn : true)
438     endif
439 else
440     summary({'lua' : ['disabled - lua supported:', false]}, section : 'Configuration', bool_yn : true)
441 endif
442
443 # Install standard documents
444 option = get_option('pandoc')
445 if not option.disabled()
446     pandoc = find_program('pandoc', required : false)
447     if pandoc.found()
448         readme_html = custom_target(
449             'README.html',
450             input: 'README.md',
451             output: 'README.html',
452             command: [pandoc, '@INPUT@', '-o', '@OUTPUT@'],
453             install: true,
454             install_dir: helpdir)
455
456         summary({'README' : ['README.html created:', true]}, section : 'Documentation', bool_yn : true)
457     else
458         summary({'README' : ['pandoc not found - README.html created:', false]}, section : 'Documentation', bool_yn : true)
459     endif
460 else
461     summary({'pandoc' : ['disabled - README.html created:', false]}, section : 'Documentation', bool_yn : true)
462 endif
463 install_data('README.md', 'COPYING', 'TODO', install_dir : helpdir)
464
465 conf_data.set('HAVE_PDF', 0)
466 poppler_glib_dep = []
467 req_version = '>=0.62'
468 option = get_option('pdf')
469 if not option.disabled()
470     poppler_glib_dep = dependency('poppler-glib', version : req_version, required : get_option('pdf'))
471     if poppler_glib_dep.found()
472         conf_data.set('HAVE_PDF', 1)
473         summary({'pdf'  : ['pdf files supported:', true]}, section : 'Configuration', bool_yn : true)
474     else
475         summary({'pdf' : ['poppler-glib ' + req_version + ' not found - pdf files supported:', false]}, section : 'Configuration', bool_yn : true)
476     endif
477 else
478     summary({'pdf' : ['disabled - pdf files supported:', false]}, section : 'Configuration', bool_yn : true)
479 endif
480
481 conf_data.set('HAVE_SPELL', 0)
482 gspell_dep = []
483 req_version = '>=1.6'
484 option = get_option('spell')
485 if not option.disabled()
486     gspell_dep = dependency('gspell-1', version : req_version, required: get_option('spell'))
487     if gspell_dep.found()
488         conf_data.set('HAVE_SPELL', 1)
489         summary({'spell' : ['spelling checks enabled', true]}, section : 'Configuration', bool_yn : true)
490     else
491         summary({'spell' : ['gspell-1 ' + req_version + ' not found - spelling checks enabled', false]}, section : 'Configuration', bool_yn : true)
492     endif
493 else
494     summary({'spell' : ['disabled - spelling checks enabled', false]}, section : 'Configuration', bool_yn : true)
495 endif
496
497 conf_data.set('HAVE_TIFF', 0)
498 tiff_dep = []
499 option = get_option('tiff')
500 if not option.disabled()
501     tiff_dep = dependency('libtiff-4', required: get_option('tiff'))
502     if tiff_dep.found()
503         if cc.has_function('TIFFClientOpen', dependencies : tiff_dep)
504             conf_data.set('HAVE_TIFF', 1)
505             summary({'tiff' : ['tiff files supported:', true]}, section : 'Configuration', bool_yn : true)
506         else
507             summary({'tiff' : ['TIFFClientOpen not found - tiff files supported:', false]}, section : 'Configuration', bool_yn : true)
508         endif
509     else
510         summary({'tiff' : ['libtiff not found - tiff files supported:', false]}, section : 'Configuration', bool_yn : true)
511     endif
512 else
513     summary({'tiff' : ['disabled - tiff files supported:', false]}, section : 'Configuration', bool_yn : true)
514 endif
515
516 conf_data.set('HAVE_FFMPEGTHUMBNAILER', 0)
517 conf_data.set('HAVE_FFMPEGTHUMBNAILER_METADATA', 0)
518 conf_data.set('HAVE_FFMPEGTHUMBNAILER_RGB', 0)
519 conf_data.set('HAVE_FFMPEGTHUMBNAILER_WH', 0)
520 libffmpegthumbnailer_dep = []
521 req_version = '>=2.1.0'
522 option = get_option('videothumbnailer')
523 if not option.disabled()
524     libffmpegthumbnailer_dep = dependency('libffmpegthumbnailer',
525         version : req_version,
526         required : get_option('videothumbnailer'))
527
528     if libffmpegthumbnailer_dep.found()
529         conf_data.set('HAVE_FFMPEGTHUMBNAILER', 1)
530         summary({'videothumbnailer' : ['thumbnails of video files supported:', true]}, section : 'Configuration', bool_yn : true)
531
532         result = cc.has_member('struct video_thumbnailer_struct', 'prefer_embedded_metadata', prefix : '#include <libffmpegthumbnailer/videothumbnailerc.h>')
533         if result
534             conf_data.set('HAVE_FFMPEGTHUMBNAILER_METADATA', 1)
535         endif
536         summary({'fmpegthumbnailer_metadata' : ['fmpegthumbnailer_metadata found:', result]}, section : 'Thumbnailer', bool_yn : true)
537
538         result = cc.has_member('struct image_data_struct', 'image_data_width', prefix : '#include <libffmpegthumbnailer/videothumbnailerc.h>' )
539         if result
540             conf_data.set('HAVE_FFMPEGTHUMBNAILER_RGB', 1)
541         endif
542         summary({'fmpegthumbnailer_rgb' : ['fmpegthumbnailer_rgb found:', result]}, section : 'Thumbnailer', bool_yn : true)
543
544         result = cc.has_function('video_thumbnailer_set_size', dependencies : libffmpegthumbnailer_dep)
545         if result
546             conf_data.set('HAVE_FFMPEGTHUMBNAILER_WH', 1)
547         endif
548         summary({'fmpegthumbnailer_set_size' : ['fmpegthumbnailer_set_size found:', result]}, section : 'Thumbnailer', bool_yn : true)
549     else
550         summary({'videothumbnailer' : ['libvideothumbnailer ' + req_version + ' not found - thumbnails of video files supported', false]}, section : 'Configuration', bool_yn : true)
551     endif
552 else
553     summary({'videothumbnailer' : ['disabled -thumbnails of video files supported', false]}, section : 'Configuration', bool_yn : true)
554 endif
555
556 conf_data.set('HAVE_WEBP', 0)
557 libwebp_dep = []
558 req_version = '>=0.6.1'
559 option = get_option('webp')
560 if not option.disabled()
561     libwebp_dep = dependency('libwebp', version : req_version, required : get_option('webp'))
562     if libwebp_dep.found()
563         conf_data.set('HAVE_WEBP', 1)
564         summary({'webp' : ['webp files supported:', true]}, section : 'Configuration', bool_yn : true)
565     else
566         summary({'webp' : ['libwebp ' + req_version + ' not found - webp files supported:', false]}, section : 'Configuration', bool_yn : true)
567     endif
568 else
569     summary({'webp' : ['disabled - webp files supported:', false]}, section : 'Configuration', bool_yn : true)
570 endif
571
572 # Check for nl_langinfo and _NL_TIME_FIRST_WEEKDAY
573 conf_data.set('HAVE__NL_TIME_FIRST_WEEKDAY', 0)
574 code = '''#include <langinfo.h>
575 #include<stdio.h>
576 int main (int argc, char ** argv) {
577     char *c;
578     c =  nl_langinfo(_NL_TIME_FIRST_WEEKDAY);
579     return 0;
580 }'''
581 if cc.links(code, name : 'nl_langinfo and _NL_TIME_FIRST_WEEKDAY')
582     conf_data.set('HAVE__NL_TIME_FIRST_WEEKDAY', 1)
583     summary({'nl_langinfo' : ['first weekday depends on locale:', true]}, section : 'Documentation', bool_yn : true)
584 else
585     summary({'nl_langinfo' : ['nl_langinfo not found - first weekday depends on locale:', false, 'first weekday defaults to Monday']}, section : 'Documentation', bool_yn : true)
586 endif
587
588 conf_data.set_quoted('GETTEXT_PACKAGE', meson.project_name())
589 conf_data.set_quoted('GQ_APPDIR', gq_appdir)
590 conf_data.set_quoted('GQ_BINDIR', gq_bindir)
591 conf_data.set_quoted('GQ_HELPDIR', gq_helpdir)
592 conf_data.set_quoted('GQ_HTMLDIR', gq_htmldir)
593 conf_data.set_quoted('GQ_LOCALEDIR', gq_localedir)
594
595 conf_data.set_quoted('PACKAGE', meson.project_name())
596 conf_data.set_quoted('PACKAGE_NAME', meson.project_name())
597 conf_data.set_quoted('PACKAGE_STRING', meson.project_version())
598 conf_data.set_quoted('PACKAGE_TARNAME', meson.project_name())
599 conf_data.set_quoted('PACKAGE_VERSION', meson.project_version())
600 conf_data.set_quoted('VERSION', meson.project_version())
601
602 configure_file(input : 'config.h.in',
603                output : 'config.h',
604                encoding : 'UTF-8',
605                configuration : conf_data)
606
607 # For gtk builder checks on .ui files
608 ui_sources = []
609
610 # Process subdirs before the sources
611 subdir('po')
612 subdir('plugins')
613
614 # Generate the executable
615 subdir('src')
616
617 # Generate the help files
618 subdir('doc')
619
620 # Generate the command line auto-complete file
621 subdir('auto-complete')
622
623 # Install other project files
624 if running_from_git
625     cmd = [find_program('gen_changelog.sh'), meson.current_source_dir(), meson.current_build_dir()]
626     custom_target(
627         'ChangeLog',
628         input: 'ChangeLog.gqview',
629         output: ['ChangeLog', 'ChangeLog.html'],
630         command: cmd,
631         install: true,
632         install_dir: helpdir)
633     meson.add_dist_script(cmd)
634     summary({'ChangeLog' : ['ChangeLog, ChangeLog.html created:', true]}, section : 'Documentation', bool_yn : true)
635 elif fs.exists('ChangeLog.html')
636     install_data('ChangeLog', 'ChangeLog.html', install_dir: helpdir)
637     summary({'ChangeLog' : ['ChangeLog, ChangeLog.html installed from dist:', true]}, section : 'Documentation', bool_yn : true)
638 endif
639
640 install_data('geeqie.png', install_dir : icondir)
641 install_data('geeqie.1', install_dir : mandir1)
642
643 i18n.merge_file(
644     input : 'org.geeqie.Geeqie.desktop.in',
645     output : 'org.geeqie.Geeqie.desktop',
646     type : 'desktop',
647     po_dir : podir,
648     install : true,
649     install_dir : join_paths(datadir, 'applications'))
650
651 i18n.merge_file(
652     input : 'org.geeqie.Geeqie.appdata.xml.in',
653     output : 'org.geeqie.Geeqie.appdata.xml',
654     type : 'xml',
655     po_dir : podir,
656     install : true,
657     install_dir : appdatadir)
658
659 configure_file(input: 'geeqie.spec.in', output: 'geeqie.spec', configuration: conf_data)
660
661 # Basic test of the executable
662 # is_parallel false is to avoid problems with images tests
663 xvfb = find_program('xvfb-run', required : false)
664 if xvfb.found()
665     test('Basic test', xvfb, args: ['--auto-servernum', geeqie_exe, '--version'], is_parallel : false, timeout: 100)
666     summary({'xvfb' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
667 else
668     summary({'xvfb' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
669 endif
670
671 # The tests are run on GitHub with all options disabled, and then
672 # Image tests use option devel as a flag so that normal users do not
673 # download the test image database.
674
675 # Image checks
676 option = get_option('devel')
677 if option.enabled()
678     if xvfb.found()
679         get_test_images_sh = find_program('get-test-images.sh', dirs : scriptsdir, required : true)
680         image_test_sh = find_program('image-test.sh', dirs : scriptsdir, required : true)
681
682         images_dir = join_paths(meson.current_build_dir(), 'test-images.p')
683
684         message('Downloading test images')
685         sources_list = run_command(get_test_images_sh, images_dir,  'https://github.com/caclark/geeqie-test.git', check: true)
686
687         sources = sources_list.stdout().strip().split('\n')
688
689         foreach image : sources
690             image_path = '@0@'.format(image)
691             path_array = image_path.split('/')
692             image_name = path_array[path_array.length() - 1]
693
694             if image_name.startswith('fail')
695                 test('Image_ ' + image_name, image_test_sh, args: [geeqie_exe, image], is_parallel : false, should_fail : true, timeout: 100)
696             else
697                 test('Image_ ' + image_name, image_test_sh, args: [geeqie_exe, image], is_parallel : false, timeout: 100)
698             endif
699         endforeach
700         summary({'Image tests' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
701     else
702         summary({'Image tests' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
703     endif
704 else
705     summary({'Image tests' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
706 endif
707
708 # Code correctness checks
709 if running_from_git
710     clang_tidy_exe = find_program('clang-tidy', required : false)
711     if clang_tidy_exe.found()
712         git_exe = find_program('git', required : true)
713
714         foreach source_file : main_sources + pan_view_sources + view_file_sources
715             if fs.name(source_file).endswith('.cc')
716                 source_file_name = fs.name(source_file)
717                 config_file = join_paths(meson.project_source_root(), '.clang-tidy')
718
719                 test('Code Correctness_ ' + source_file_name, clang_tidy_exe, args : ['-p', './build', '-quiet', '--config-file', config_file,  source_file], timeout : 100)
720             endif
721         endforeach
722
723         summary({'Code Correctness' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
724     else
725         summary({'Code Correctness' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
726     endif
727 else
728     summary({'Code Correctness' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
729 endif
730
731 # Single value enum checks
732 enum_check_sh = find_program('enum-check.sh', dirs : scriptsdir, required : true)
733 if enum_check_sh.found()
734     foreach source_file : main_sources + pan_view_sources + view_file_sources
735         source_file_name = fs.name(source_file)
736         test('Single Value enum_ ' + source_file_name, enum_check_sh, args : [source_file], timeout : 100)
737     endforeach
738
739     summary({'Single Value enum' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
740 else
741     summary({'Single Value enum' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
742 endif
743
744 # Debug statement checks
745 debug_check_sh = find_program('debug-check.sh', dirs : scriptsdir, required : true)
746 if debug_check_sh.found()
747     foreach source_file : main_sources + pan_view_sources + view_file_sources
748         source_file_name = fs.name(source_file)
749         if (source_file_name != 'debug.h')
750             test('Debug Statements_ ' + source_file_name, debug_check_sh, args : [source_file], timeout : 100)
751         endif
752     endforeach
753
754     summary({'Debug Statements' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
755 else
756     summary({'Debug Statements' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
757 endif
758
759 # Temporary comments checks
760 tmp_comments_check_sh = find_program('temporary-comments-check.sh', dirs : scriptsdir, required : true)
761 if tmp_comments_check_sh.found()
762     foreach source_file : main_sources + pan_view_sources + view_file_sources
763         source_file_name = fs.name(source_file)
764         if (source_file_name != 'debug.h')
765             test('Temporary Comments_ ' + source_file_name, tmp_comments_check_sh, args : [source_file], timeout : 100)
766         endif
767     endforeach
768
769     summary({'Temporary Comments' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
770 else
771     summary({'Temporary Comments' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
772 endif
773
774 # Lua test
775 option = get_option('lua')
776 if not option.disabled()
777     if lua_dep.found()
778         if xvfb.found()
779             lua_test_sh = find_program('lua-test.sh', dirs : scriptsdir, required : true)
780             test('Lua test', lua_test_sh, args: [geeqie_exe], is_parallel : false, timeout: 100)
781
782             summary({'lua' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
783         else
784             summary({'lua' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
785         endif
786     else
787         summary({'lua' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
788     endif
789 else
790     summary({'lua' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
791 endif
792
793 # Ancillary files test
794 test_ancillary_files_sh = find_program('test-ancillary-files.sh', dirs : scriptsdir, required : true)
795 test('Ancillary files', test_ancillary_files_sh, args: [meson.current_source_dir()], timeout: 100)
796
797 summary({'Ancillary files' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)