Include clang-tidy check
[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           geeqie.desktop
29 # [gq_]appdir   /usr/local/share/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 # podir         project_root/po
38
39 # * See meson_options.txt file
40
41 project(
42     'geeqie',
43     'c',
44     'cpp',
45     version : run_command('./version.sh', check : true).stdout().strip(),
46     license : ['GPL-2.0-or-later'],
47     meson_version : '>=0.56.2',
48     default_options : ['cpp_std=c++14', 'warning_level=3', 'buildtype=debugoptimized', 'cpp_link_args=-rdynamic']
49 )
50
51 # To inhibit warnings from the generated files icons_inline.h and ui_icons.h
52 add_global_arguments('-Wno-overlength-strings', language : 'c')
53
54 # To compile originally-C files as C++
55 add_global_arguments('-Wno-error=deprecated-declarations', language : 'cpp')
56
57 # Project requirements
58 project_sources = []
59 gnome = import('gnome')
60 thread_dep = dependency('threads')
61 cc = meson.get_compiler('c')
62 i18n = import('i18n')
63 fs = import('fs')
64 configuration_inc = include_directories('.')
65
66 # Extended stack trace using backward-app
67 option = get_option('devel')
68 if option.enabled()
69     if cc.has_link_argument('-ldwarf')
70         add_project_link_arguments('-ldwarf', language: 'cpp')
71     endif
72 endif
73
74 # External programs
75 gdk_pixbuf_csource = find_program('gdk-pixbuf-csource', required : true)
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
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_quoted('VERSION', meson.project_version())
152 conf_data.set('DEBUG', debug)
153
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 libdw_dep = []
165 libunwind_dep = []
166 option = get_option('devel')
167 if option.enabled()
168     libdw_dep = dependency('libdw', required : true)
169     if libdw_dep.found()
170         libunwind_dep = dependency('libunwind', required : true)
171         if libunwind_dep.found()
172             conf_data.set('HAVE_DEVELOPER', 1)
173             summary({'developer mode' : ['extended stacktrace:', true]}, section : 'Debugging', bool_yn : true)
174         else
175             summary({'developer mode' : ['libunwind not found. extended stacktrace:', false]}, section : 'Debugging', bool_yn : true)
176         endif
177     else
178         summary({'developer mode' : ['libdw not found. extended stacktrace:', false]}, section : 'Debugging', bool_yn : true)
179     endif
180 else
181     summary({'developer mode' : ['extended stacktrace:', false]}, section : 'Debugging', bool_yn : true)
182 endif
183
184 # Required only for seg. fault stacktrace and backtrace debugging
185 option = get_option('execinfo')
186 libexecinfo_dep = []
187 if not option.disabled()
188     result = cc.check_header('execinfo.h')
189     if result
190         # Include unconditionally dependency for NetBSD.
191         libexecinfo_dep = cc.find_library('execinfo', required : false)
192         conf_data.set('HAVE_EXECINFO_H', 1)
193         summary({'execinfo' : ['stacktrace supported:', true]}, section : 'Debugging', bool_yn : true)
194     else
195         summary({'execinfo' : ['stacktrace supported:', false]}, section : 'Debugging', bool_yn : true)
196     endif
197 else
198     summary({'execinfo' : ['stacktrace supported:', false]}, section : 'Debugging', bool_yn : true)
199 endif
200
201 libarchive_dep = []
202 req_version = '>=3.4.0'
203 option = get_option('archive')
204 if not option.disabled()
205     libarchive_dep = dependency('libarchive', version : req_version, required : get_option('archive'))
206     if libarchive_dep.found()
207         conf_data.set('HAVE_ARCHIVE', 1)
208         summary({'archive' : ['archive files e.g. .zip supported:', true]}, section : 'Configuration', bool_yn : true)
209     else
210         summary({'archive' : ['libarchive ' + req_version + ' not found - archive files e.g. .zip supported::', false]}, section : 'Configuration', bool_yn : true)
211     endif
212 else
213     summary({'archive' : ['disabled - archive files e.g. .zip supported:', false]}, section : 'Configuration', bool_yn : true)
214 endif
215
216 lcms_dep = []
217 req_version = '>=2.0'
218 option = get_option('cms')
219 if not option.disabled()
220     xxd = find_program('xxd', 'xxdi.pl', required : false)
221     if xxd.found()
222         lcms_dep = dependency('lcms2', version : req_version, required : get_option('cms'))
223         if lcms_dep.found()
224             conf_data.set('HAVE_LCMS', 1)
225             conf_data.set('HAVE_LCMS2', 1)
226             summary({'cms' : ['color management supported:', true]}, section : 'Configuration', bool_yn : true)
227         else
228             summary({'cms' : ['lcms2' + req_version + ' not found - color management supported:', false]}, section : 'Configuration', bool_yn : true)
229         endif
230     else
231         summary({'cms' : ['xxd or xxdi.pl not found - color management supported:', false]}, section : 'Configuration', bool_yn : true)
232     endif
233 else
234     summary({'cms' : ['disabled - color management supported:', false]}, section : 'Configuration', bool_yn : true)
235 endif
236
237 ddjvuapi_dep = []
238 req_version = '>=2.5.27'
239 option = get_option('djvu')
240 if not option.disabled()
241     ddjvuapi_dep = dependency('ddjvuapi', version : req_version, required : get_option('djvu'))
242     if ddjvuapi_dep.found()
243         conf_data.set('HAVE_DJVU', 1)
244         summary({'djvu' : ['djvu files supported:', true]}, section : 'Configuration', bool_yn : true)
245     else
246         summary({'djvu' : ['ddjvuapi ' + req_version + ' not found - djvu files supported:', false]}, section : 'Configuration', bool_yn : true)
247     endif
248 else
249     summary({'djvu' : ['disabled - djvu files supported:', false]}, section : 'Configuration', bool_yn : true)
250 endif
251
252 option = get_option('evince')
253 if not option.disabled()
254     evince = find_program('evince', required : false)
255     if evince.found()
256         summary({'print preview' : ['print preview supported:', true]}, section : 'Configuration', bool_yn : true)
257     else
258         summary({'print preview' : ['evince not found - print preview supported:', false]}, section : 'Configuration', bool_yn : true)
259     endif
260 else
261     summary({'print preview' : ['disabled - print preview supported:', false]}, section : 'Configuration', bool_yn : true)
262 endif
263
264 # Required only for seg. fault stacktrace and backtrace debugging
265 option = get_option('execinfo')
266 if not option.disabled()
267     result = cc.check_header('execinfo.h')
268     if result
269         conf_data.set('HAVE_EXECINFO_H', 1)
270         summary({'execinfo' : ['stacktrace supported:', true]}, section : 'Configuration', bool_yn : true)
271     else
272         summary({'execinfo' : ['stacktrace supported:', false]}, section : 'Configuration', bool_yn : true)
273     endif
274 else
275     summary({'execinfo' : ['stacktrace supported:', false]}, section : 'Configuration', bool_yn : true)
276 endif
277
278 exiv2_dep = []
279 req_version = '>=0.11'
280 option = get_option('exiv2')
281 if not option.disabled()
282     exiv2_dep = dependency('exiv2', version : req_version, required : get_option('exiv2'))
283     if exiv2_dep.found()
284         conf_data.set('HAVE_EXIV2', 1)
285         summary({'exiv2' : ['image metadata processed by exiv2:', true]}, section : 'Configuration', bool_yn : true)
286     else
287         summary({'exiv2' : ['exiv2 ' + req_version + ' not found - image data not processed by exiv2:', false]}, section : 'Configuration', bool_yn : true)
288     endif
289 else
290     summary({'exiv2' : ['disabled - image data processed by exiv2:', false]}, section : 'Configuration', bool_yn : true)
291 endif
292
293 champlain_dep = []
294 champlain_gtk_dep = []
295 clutter_dep = []
296 clutter_gtk_dep = []
297 req_version_champlain = '>=0.12'
298 req_version_champlain_gtk = '>=0.12'
299 req_version_clutter = '>=1.0'
300 req_version_clutter_gtk = '>=1.0'
301 option = get_option('gps-map')
302 if not option.disabled()
303     champlain_dep = dependency('champlain-0.12', version : req_version_champlain, required : get_option('gps-map'))
304     champlain_gtk_dep = dependency('champlain-gtk-0.12', version : req_version_champlain_gtk, required : get_option('gps-map'))
305     if champlain_dep.found() and champlain_gtk_dep.found()
306         clutter_dep = dependency('clutter-1.0', version : req_version_clutter, required : get_option('gps-map'))
307         clutter_gtk_dep = dependency('clutter-gtk-1.0', version : req_version_clutter_gtk, required : get_option('gps-map'))
308         if clutter_dep.found() and clutter_gtk_dep.found()
309             conf_data.set('HAVE_CLUTTER', 1)
310             conf_data.set('HAVE_LIBCHAMPLAIN', 1)
311             conf_data.set('HAVE_LIBCHAMPLAIN_GTK', 1)
312             summary({'gps-map' : ['GPS map displayed', true]}, section : 'Configuration', bool_yn : true)
313         else
314             if not clutter_dep.found()
315                 summary({'gps-map-clutter' : ['clutter-1.0 ' + req_version_clutter + ' not found - GPS map displayed:', false]}, section : 'Configuration', bool_yn : true)
316             endif
317             if not clutter_gtk_dep.found()
318                 summary({'gps-map-clutter-gtk' : ['clutter-gtk-1.0 ' + req_version_clutter_gtk + ' not found - GPS map displayed:', false]}, section : 'Configuration', bool_yn : true)
319             endif
320         endif
321     else
322         if not champlain_dep.found()
323             summary({'gps-map-champlain' : ['champlain-0.12 ' + req_version_champlain + ' not found - GPS map displayed:', false]}, section : 'Configuration', bool_yn : true)
324         endif
325         if not champlain_gtk_dep.found()
326             summary({'gps-map-champlain-gtk' : ['champlain-gtk-0.12 ' + req_version_champlain_gtk + ' not found - GPS map displayed:', false]}, section : 'Configuration', bool_yn : true)
327         endif
328     endif
329 else
330     summary({'gps-map' : ['disabled - GPS map displayed:', false]}, section : 'Configuration', bool_yn : true)
331 endif
332
333 libheif_dep = []
334 req_version = '>=1.3.2'
335 option = get_option('heif')
336 if not option.disabled()
337     libheif_dep = dependency('libheif', version : req_version, required : get_option('heif'))
338     if libheif_dep.found()
339         conf_data.set('HAVE_HEIF', 1)
340         summary({'heif' : ['heif files supported:', true]}, section : 'Configuration', bool_yn : true)
341     else
342         summary({'heif' : ['libheif ' + req_version + ' not found - heif files supported:', false]}, section : 'Configuration', bool_yn : true)
343     endif
344 else
345     summary({'heif' : ['disabled - heif files supported:', false]}, section : 'Configuration', bool_yn : true)
346 endif
347
348 libopenjp2_dep = []
349 req_version = '>=2.3.0'
350 option = get_option('j2k')
351 if not option.disabled()
352     libopenjp2_dep = dependency('libopenjp2', version : req_version, required : get_option('j2k'))
353     if libopenjp2_dep.found()
354         conf_data.set('HAVE_J2K', 1)
355         summary({'j2k' : ['j2k files supported:', true]}, section : 'Configuration', bool_yn : true)
356     else
357         summary({'j2k' : ['libopenjp2 ' + req_version + ' not found - j2k files supported:', false]}, section : 'Configuration', bool_yn : true)
358     endif
359 else
360     summary({'j2k' : ['disabled - j2k files supported:', false]}, section : 'Configuration', bool_yn : true)
361 endif
362
363 libjpeg_dep = []
364 option = get_option('jpeg')
365 if not option.disabled()
366 libjpeg_dep = dependency('libjpeg', required : get_option('jpeg'))
367     if libjpeg_dep.found()
368         if cc.has_function('jpeg_destroy_decompress', dependencies : libjpeg_dep)
369             conf_data.set('HAVE_JPEG', 1)
370             summary({'jpeg' : ['jpeg files supported:', true]}, section : 'Configuration', bool_yn : true)
371         else
372             summary({'jpeg' : ['jpeg_destroy_decompress not found - jpeg files supported:', false]}, section : 'Configuration', bool_yn : true)
373         endif
374     else
375         summary({'jpeg' : ['libjpeg: not found', false]}, section : 'Configuration', bool_yn : true)
376     endif
377 else
378     summary({'jpeg' : ['disabled - jpeg files supported:', false]}, section : 'Configuration', bool_yn : true)
379 endif
380
381 libjxl_dep = []
382 req_version = '>=0.3.7'
383 option = get_option('jpegxl')
384 if not option.disabled()
385     libjxl_dep = dependency('libjxl', version : req_version, required : get_option('jpegxl'))
386     if libjxl_dep.found()
387         conf_data.set('HAVE_JPEGXL', 1)
388         summary({'jpegxl' : ['jpegxl files supported:', true]}, section : 'Configuration', bool_yn : true)
389     else
390         summary({'jpegxl' : ['libjxl ' + req_version + ' not found - jpegxl files supported:', false]}, section : 'Configuration', bool_yn : true)
391     endif
392 else
393     summary({'jpegxl' : ['disabled - jpegxl files supported:', false]}, section : 'Configuration', bool_yn : true)
394 endif
395
396 libraw_dep = []
397 req_version = '>=0.20'
398 option = get_option('libraw')
399 if not option.disabled()
400     libraw_dep = dependency('libraw', version : req_version, required : get_option('libraw'))
401     if libraw_dep.found()
402         conf_data.set('HAVE_RAW', 1)
403         summary({'libraw' : ['.cr3 files supported:', true]}, section : 'Configuration', bool_yn : true)
404     else
405         summary({'libraw' : ['libraw ' + req_version + ' not found - .cr3 files supported:', false]}, section : 'Configuration', bool_yn : true)
406     endif
407 else
408     summary({'libraw' : ['disabled - .cr3 files supported:', false]}, section : 'Configuration', bool_yn : true)
409 endif
410
411 lua_dep = []
412 req_version = '>=5.3'
413 option = get_option('lua')
414 if not option.disabled()
415     foreach name : ['lua', 'lua5.3', 'lua-5.3', 'lua53']
416         lua_dep = dependency(name, version: req_version, required: get_option('lua'))
417         if lua_dep.found()
418             break
419         endif
420     endforeach
421     if lua_dep.found()
422         conf_data.set('HAVE_LUA', 1)
423         summary({'lua' : ['lua supported:', true]}, section : 'Configuration', bool_yn : true)
424     else
425         summary({'lua' : ['lua ' + req_version + ' not found - lua supported:', false]}, section : 'Configuration', bool_yn : true)
426     endif
427 else
428     summary({'lua' : ['disabled - lua supported:', false]}, section : 'Configuration', bool_yn : true)
429 endif
430
431 # Install standard documents
432 option = get_option('pandoc')
433 if not option.disabled()
434     pandoc = find_program('pandoc', required : false)
435     if pandoc.found()
436         readme_html = custom_target(
437             'README.html',
438             input: 'README.md',
439             output: 'README.html',
440             command: [pandoc, '@INPUT@', '-o', '@OUTPUT@'],
441             install: true,
442             install_dir: helpdir)
443
444         summary({'README' : ['README.html created:', true]}, section : 'Documentation', bool_yn : true)
445     else
446         summary({'README' : ['pandoc not found - README.html created:', false]}, section : 'Documentation', bool_yn : true)
447     endif
448 else
449     summary({'pandoc' : ['disabled - README.html created:', false]}, section : 'Documentation', bool_yn : true)
450 endif
451 install_data('README.md', 'COPYING', 'TODO', install_dir : helpdir)
452
453 poppler_glib_dep = []
454 req_version = '>=0.62'
455 option = get_option('pdf')
456 if not option.disabled()
457     poppler_glib_dep = dependency('poppler-glib', version : req_version, required : get_option('pdf'))
458     if poppler_glib_dep.found()
459         conf_data.set('HAVE_PDF', 1)
460         summary({'pdf'  : ['pdf files supported:', true]}, section : 'Configuration', bool_yn : true)
461     else
462         summary({'pdf' : ['poppler-glib ' + req_version + ' not found - pdf files supported:', false]}, section : 'Configuration', bool_yn : true)
463     endif
464 else
465     summary({'pdf' : ['disabled - pdf files supported:', false]}, section : 'Configuration', bool_yn : true)
466 endif
467
468 gspell_dep = []
469 req_version = '>=1.6'
470 option = get_option('spell')
471 if not option.disabled()
472     gspell_dep = dependency('gspell-1', version : req_version, required: get_option('spell'))
473     if gspell_dep.found()
474         conf_data.set('HAVE_SPELL', 1)
475         summary({'spell' : ['spelling checks enabled', true]}, section : 'Configuration', bool_yn : true)
476     else
477         summary({'spell' : ['gspell-1 ' + req_version + ' not found - spelling checks enabled', false]}, section : 'Configuration', bool_yn : true)
478     endif
479 else
480     summary({'spell' : ['disabled - spelling checks enabled', false]}, section : 'Configuration', bool_yn : true)
481 endif
482
483 tiff_dep = []
484 option = get_option('tiff')
485 if not option.disabled()
486     tiff_dep = dependency('libtiff-4', required: get_option('tiff'))
487     if tiff_dep.found()
488         if cc.has_function('TIFFClientOpen', dependencies : tiff_dep)
489             conf_data.set('HAVE_TIFF', 1)
490             summary({'tiff' : ['tiff files supported:', true]}, section : 'Configuration', bool_yn : true)
491         else
492             summary({'tiff' : ['TIFFClientOpen not found - tiff files supported:', false]}, section : 'Configuration', bool_yn : true)
493         endif
494     else
495         summary({'tiff' : ['libtiff not found - tiff files supported:', false]}, section : 'Configuration', bool_yn : true)
496     endif
497 else
498     summary({'tiff' : ['disabled - tiff files supported:', false]}, section : 'Configuration', bool_yn : true)
499 endif
500
501 libffmpegthumbnailer_dep = []
502 req_version = '>=2.1.0'
503 option = get_option('videothumbnailer')
504 if not option.disabled()
505     libffmpegthumbnailer_dep = dependency('libffmpegthumbnailer',
506         version : req_version,
507         required : get_option('videothumbnailer'))
508
509     if libffmpegthumbnailer_dep.found()
510         conf_data.set('HAVE_FFMPEGTHUMBNAILER', 1)
511         summary({'videothumbnailer' : ['thumbnails of video files supported:', true]}, section : 'Configuration', bool_yn : true)
512
513         result = cc.has_member('struct video_thumbnailer_struct', 'prefer_embedded_metadata', prefix : '#include <libffmpegthumbnailer/videothumbnailerc.h>')
514         if result
515             conf_data.set('HAVE_FFMPEGTHUMBNAILER_METADATA', 1)
516         endif
517         summary({'fmpegthumbnailer_metadata' : ['fmpegthumbnailer_metadata found:', result]}, section : 'Thumbnailer', bool_yn : true)
518
519         result = cc.has_member('struct image_data_struct', 'image_data_width', prefix : '#include <libffmpegthumbnailer/videothumbnailerc.h>' )
520         if result
521             conf_data.set('HAVE_FFMPEGTHUMBNAILER_RGB', 1)
522         endif
523         summary({'fmpegthumbnailer_rgb' : ['fmpegthumbnailer_rgb found:', result]}, section : 'Thumbnailer', bool_yn : true)
524
525         result = cc.has_function('video_thumbnailer_set_size', dependencies : libffmpegthumbnailer_dep)
526         if result
527             conf_data.set('HAVE_FFMPEGTHUMBNAILER_WH', 1)
528         endif
529         summary({'fmpegthumbnailer_set_size' : ['fmpegthumbnailer_set_size found:', result]}, section : 'Thumbnailer', bool_yn : true)
530     else
531         summary({'videothumbnailer' : ['libvideothumbnailer ' + req_version + ' not found - thumbnails of video files supported', false]}, section : 'Configuration', bool_yn : true)
532     endif
533 else
534     summary({'videothumbnailer' : ['disabled -thumbnails of video files supported', false]}, section : 'Configuration', bool_yn : true)
535 endif
536
537 # libpixbufloader-webp is not loaded as part of libgdk-pixbuf. Just issue
538 # a warning if not installed
539 libwebp_dir = dependency('gdk-pixbuf-2.0', method: 'pkg-config').get_variable(pkgconfig: 'gdk_pixbuf_moduledir', internal: 'gdk_pixbuf_moduledir')
540
541 if libwebp_dir.contains('loaders')
542     libwebp_dep = cc.find_library('pixbufloader-webp', dirs : libwebp_dir, required : false)
543     if libwebp_dep.found()
544         summary({'webp' : ['webp files supported:', true]}, section : 'Configuration', bool_yn : true)
545     else
546         summary({'webp' : ['webp-pixbuf-loader not installed - webp files supported:', false]}, section : 'Configuration', bool_yn : true)
547     endif
548 else
549     summary({'webp' : ['webp-pixbuf-loader not installed - webp files supported:', false]}, section : 'Configuration', bool_yn : true)
550 endif
551
552 # Check for nl_langinfo and _NL_TIME_FIRST_WEEKDAY
553 code = '''#include <langinfo.h>
554 #include<stdio.h>
555 int main (int argc, char ** argv) {
556     char *c;
557     c =  nl_langinfo(_NL_TIME_FIRST_WEEKDAY);
558     return 0;
559 }'''
560 if cc.links(code, name : 'nl_langinfo and _NL_TIME_FIRST_WEEKDAY')
561     conf_data.set('HAVE__NL_TIME_FIRST_WEEKDAY', 1)
562     summary({'nl_langinfo' : ['first weekday depends on locale:', true]}, section : 'Documentation', bool_yn : true)
563 else
564     summary({'nl_langinfo' : ['nl_langinfo not found - first weekday depends on locale:', false, 'first weekday defaults to Monday']}, section : 'Documentation', bool_yn : true)
565 endif
566
567 conf_data.set_quoted('GETTEXT_PACKAGE', meson.project_name())
568 conf_data.set_quoted('GQ_APPDIR', gq_appdir)
569 conf_data.set_quoted('GQ_BINDIR', gq_bindir)
570 conf_data.set_quoted('GQ_HELPDIR', gq_helpdir)
571 conf_data.set_quoted('GQ_HTMLDIR', gq_htmldir)
572 conf_data.set_quoted('GQ_LOCALEDIR', gq_localedir)
573
574 conf_data.set_quoted('PACKAGE', meson.project_name())
575 conf_data.set_quoted('PACKAGE_NAME', meson.project_name())
576 conf_data.set_quoted('PACKAGE_STRING', meson.project_version())
577 conf_data.set_quoted('PACKAGE_TARNAME', meson.project_name())
578 conf_data.set_quoted('PACKAGE_VERSION', meson.project_version())
579 conf_data.set_quoted('VERSION', meson.project_version())
580
581 configure_file(input : 'config.h.in',
582                output : 'config.h',
583                encoding : 'UTF-8',
584                configuration : conf_data)
585
586 # For shellcheck on scripts
587 script_sources = []
588 subdir('scripts')
589
590 # For gtk builder checks on .ui files
591 ui_sources = []
592
593 # Process subdirs before the sources
594 subdir('po')
595 subdir('plugins')
596
597 # Generate the executable
598 subdir('src')
599
600 # Generate the help files
601 subdir('doc')
602
603 # Install other project files
604 if running_from_git
605     cmd = [find_program('gen_changelog.sh'), meson.current_source_dir(), meson.current_build_dir()]
606     custom_target(
607         'ChangeLog',
608         input: 'ChangeLog.gqview',
609         output: ['ChangeLog', 'ChangeLog.html'],
610         command: cmd,
611         install: true,
612         install_dir: helpdir)
613     meson.add_dist_script(cmd)
614     summary({'ChangeLog' : ['ChangeLog, ChangeLog.html created:', true]}, section : 'Documentation', bool_yn : true)
615 elif fs.exists('ChangeLog.html')
616     install_data('ChangeLog', 'ChangeLog.html', install_dir: helpdir)
617     summary({'ChangeLog' : ['ChangeLog, ChangeLog.html installed from dist:', true]}, section : 'Documentation', bool_yn : true)
618 endif
619
620 install_data('geeqie.png', install_dir : icondir)
621 install_data('geeqie.1', install_dir : mandir1)
622
623 i18n.merge_file(
624     input : 'geeqie.desktop.in',
625     output : 'geeqie.desktop',
626     type : 'desktop',
627     po_dir : podir,
628     install : true,
629     install_dir : join_paths(datadir, 'applications'))
630
631 i18n.merge_file(
632     input : 'org.geeqie.Geeqie.appdata.xml.in',
633     output : 'org.geeqie.Geeqie.appdata.xml',
634     type : 'xml',
635     po_dir : podir,
636     install : true,
637     install_dir : appdatadir)
638
639 configure_file(input: 'geeqie.spec.in', output: 'geeqie.spec', configuration: conf_data)
640
641 # Basic test of the executable
642 # is_parallel false is to avoid problems with images tests
643 xvfb = find_program('xvfb-run', required : false)
644 if xvfb.found()
645     test('Basic test', xvfb, args: ['--auto-servernum', geeqie_exe, '--version'], is_parallel : false, timeout: 100)
646     summary({'xvfb' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
647 else
648     summary({'xvfb' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
649 endif
650
651 # The tests are run on GitHub with all options disabled, and then
652 # with all or most options enabled. Shellcheck and GtkBuilder need only
653 # be run once when options are disabled. Use option archive as a flag.
654 # Image tests use option devel as a flag so that normal users do not
655 # download the test image database.
656
657 # Shellcheck
658 option = get_option('archive')
659 if option.disabled()
660     shellcheck_exe = find_program('shellcheck', required : false)
661     script_sources += files('gen_changelog.sh',
662     'geeqie-install-debian.sh',
663     'version.sh')
664
665     if shellcheck_exe.found()
666         foreach script : script_sources
667             script_path = '@0@'.format(script)
668             test('Shellcheck_ ' + script_path, shellcheck_exe, args: ['--norc', '--shell=sh', '--enable=add-default-case,avoid-nullary-conditions,check-unassigned-uppercase,deprecate-which,quote-safe-variables', script], timeout: 100)
669         endforeach
670         summary({'shellcheck' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
671     else
672         summary({'shellcheck' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
673     endif
674 else
675     summary({'shellcheck' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
676 endif
677
678 # GtkBuilder .ui check
679 option = get_option('archive')
680 if option.disabled()
681     if xvfb.found()
682         gtk_builder_tool = find_program('gtk-builder-tool', required : false)
683         if gtk_builder_tool.found()
684             foreach ui_file : ui_sources
685                 ui_path = '@0@'.format(ui_file)
686                 test('UI Build_ ' + ui_path, xvfb, args: ['--auto-servernum', gtk_builder_tool.full_path(), 'validate', ui_file], timeout: 100)
687             endforeach
688             summary({'gtk-builder-tool' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
689         else
690             summary({'gtk-builder-tool' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
691         endif
692     else
693         summary({'gtk-builder-tool xvfb' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
694     endif
695 else
696     summary({'gtk-builder-tool xvfb' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
697 endif
698
699 # Image checks
700 option = get_option('devel')
701 if option.enabled()
702     if xvfb.found()
703         get_test_images_sh = find_program('get-test-images.sh', dirs : scriptsdir, required : true)
704         image_test_sh = find_program('image-test.sh', dirs : scriptsdir, required : true)
705
706         images_dir = join_paths(meson.current_build_dir(), 'test-images.p')
707
708         message('Downloading test images')
709         sources_list = run_command(get_test_images_sh, images_dir,  'https://github.com/caclark/geeqie-test.git', check: true)
710
711         sources = sources_list.stdout().strip().split('\n')
712
713         foreach image : sources
714             image_path = '@0@'.format(image)
715             path_array = image_path.split('/')
716             image_name = path_array[path_array.length() - 1]
717
718             if image_name.startswith('fail')
719                 test('Image_ ' + image_name, image_test_sh, args: [geeqie_exe, image], is_parallel : false, should_fail : true, timeout: 100)
720             else
721                 test('Image_ ' + image_name, image_test_sh, args: [geeqie_exe, image], is_parallel : false, timeout: 100)
722             endif
723         endforeach
724         summary({'Image tests' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
725     else
726         summary({'Image tests' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
727     endif
728 else
729     summary({'Image tests' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
730 endif
731
732 # Code correctness checks
733 if running_from_git
734     clang_tidy_exe = find_program('clang-tidy', required : false)
735     if clang_tidy_exe.found()
736         git_exe = find_program('git', required : true)
737         modified_file_list = run_command(git_exe, 'diff', '--name-only', check: true)
738         modified_files = modified_file_list.stdout().strip().split('\n')
739
740         foreach modified_file : modified_files
741             if modified_file.endswith('.cc')
742                 modified_file_path = '@0@'.format(modified_file)
743                 path_array = modified_file_path.split('/')
744                 modified_file_name = path_array[path_array.length() - 1]
745                 modified_file_full_path = join_paths(meson.project_source_root(), modified_file)
746
747                 test('Code Correctness_ ' + modified_file_name, clang_tidy_exe, args : ['-p', './build', '-quiet', modified_file_full_path], timeout : 100)
748             endif
749         endforeach
750
751         summary({'Code Correctness' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
752     else
753         summary({'Code Correctness' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
754     endif
755 else
756     summary({'Code Correctness' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
757 endif