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