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