Include check for existence of xvfb in meson.build
[geeqie.git] / meson.build
index d7c1f73..660aa62 100644 (file)
@@ -44,15 +44,14 @@ project(
     'cpp',
     version : run_command('./version.sh', check : true).stdout().strip(),
     license : ['GPL-2.0-or-later'],
-    meson_version : '>=0.53.0',
-    default_options : ['warning_level=3', 'buildtype=debugoptimized']
+    meson_version : '>=0.56.2',
+    default_options : ['warning_level=3', 'buildtype=debugoptimized', 'cpp_link_args=-rdynamic']
 )
 
 # To inhibit warnings from the generated files icons_inline.h and ui_icons.h
 add_global_arguments('-Wno-overlength-strings', language : 'c')
 
 # To compile originally-C files as C++
-add_global_arguments('-fpermissive', language : 'cpp')
 add_global_arguments('-Wno-error=deprecated-declarations', language : 'cpp')
 add_global_arguments('-Wno-error=sign-compare', language : 'cpp')
 add_global_arguments('-Wno-error=return-type', language : 'cpp')
@@ -68,18 +67,27 @@ i18n = import('i18n')
 fs = import('fs')
 configuration_inc = include_directories('.')
 
+# Extended stack trace using backward-app
+option = get_option('devel')
+if option.enabled()
+    if cc.has_link_argument('-ldwarf')
+        add_project_link_arguments('-ldwarf', language: 'cpp')
+    endif
+endif
+
 # External programs
 gdk_pixbuf_csource = find_program('gdk-pixbuf-csource', required : true)
+glib_compile_resources = find_program('glib-compile-resources', required : true)
 glib_genmarshal = find_program('glib-genmarshal', required : true)
-gnome_doc_tool = find_program('yelp-build', required : false)
-if gnome_doc_tool.found()
-    summary({'help' : ['Help files created:', true]}, section : 'Documentation', bool_yn : true)
+
+option = get_option('git')
+if not option.disabled()
+    running_from_git = find_program('git', required: false).found() and fs.is_dir('.git')
 else
-    summary({'help' : ['yelp-build not found - Help files created:', false]}, section : 'Documentation', bool_yn : true)
+    running_from_git = false
+    summary({'git' : ['disabled - ChangeLog, ChangeLog.html, lua-api help file created:', false]}, section : 'Documentation', bool_yn : true)
 endif
 
-running_from_git = find_program('git', required: false).found() and fs.is_dir('.git')
-
 debug = get_option('debug')
 
 # Note that main.cc sets prefix to the directory above where the executable is run from.
@@ -132,7 +140,8 @@ htmldir = join_paths(prefix, gq_htmldir)
 icondir = join_paths(datadir, 'pixmaps')
 mandir1 = join_paths(datadir, 'man', 'man1')
 
-podir = join_paths(meson.source_root(), 'po')
+podir = join_paths(meson.project_source_root(), 'po')
+scriptsdir = join_paths(meson.project_source_root(), 'scripts')
 
 summary({'gq_appdir': gq_appdir,
         'gq_bindir': gq_helpdir,
@@ -146,9 +155,50 @@ conf_data = configuration_data()
 conf_data.set_quoted('VERSION', meson.project_version())
 conf_data.set('DEBUG', debug)
 
-gtk_dep = dependency('gtk+-3.0', version : '>=3.22', required: true)
+option = get_option('gtk4')
+if option.enabled()
+    gtk_dep = dependency('gtk4', required: true)
+    conf_data.set('HAVE_GTK4', 1)
+else
+    gtk_dep = dependency('gtk+-3.0', version : '>=3.24', required: true)
+endif
 glib_dep = dependency('glib-2.0', version : '>=2.52', required: true)
 
+# Required only when backward-cpp is used
+libdw_dep = []
+libunwind_dep = []
+option = get_option('devel')
+if option.enabled()
+    libdw_dep = dependency('libdw', required : true)
+    if libdw_dep.found()
+        libunwind_dep = dependency('libunwind', required : true)
+        if libunwind_dep.found()
+            conf_data.set('HAVE_DEVELOPER', 1)
+            summary({'developer mode' : ['extended stacktrace:', true]}, section : 'Debugging', bool_yn : true)
+        else
+            summary({'developer mode' : ['libunwind not found. extended stacktrace:', false]}, section : 'Debugging', bool_yn : true)
+        endif
+    else
+        summary({'developer mode' : ['libdw not found. extended stacktrace:', false]}, section : 'Debugging', bool_yn : true)
+    endif
+else
+    summary({'developer mode' : ['extended stacktrace:', false]}, section : 'Debugging', bool_yn : true)
+endif
+
+# Required only for seg. fault stacktrace and backtrace debugging
+option = get_option('execinfo')
+if not option.disabled()
+    result = cc.check_header('execinfo.h')
+    if result
+        conf_data.set('HAVE_EXECINFO_H', 1)
+        summary({'execinfo' : ['stacktrace supported:', true]}, section : 'Debugging', bool_yn : true)
+    else
+        summary({'execinfo' : ['stacktrace supported:', false]}, section : 'Debugging', bool_yn : true)
+    endif
+else
+    summary({'execinfo' : ['stacktrace supported:', false]}, section : 'Debugging', bool_yn : true)
+endif
+
 libarchive_dep = []
 req_version = '>=3.4.0'
 option = get_option('archive')
@@ -168,13 +218,18 @@ lcms_dep = []
 req_version = '>=2.0'
 option = get_option('cms')
 if not option.disabled()
-    lcms_dep = dependency('lcms2', version : req_version, required : get_option('cms'))
-    if lcms_dep.found()
-        conf_data.set('HAVE_LCMS', 1)
-        conf_data.set('HAVE_LCMS2', 1)
-        summary({'cms' : ['color management supported:', true]}, section : 'Configuration', bool_yn : true)
+    xxd = find_program('xxd', 'xxdi.pl', required : false)
+    if xxd.found()
+        lcms_dep = dependency('lcms2', version : req_version, required : get_option('cms'))
+        if lcms_dep.found()
+            conf_data.set('HAVE_LCMS', 1)
+            conf_data.set('HAVE_LCMS2', 1)
+            summary({'cms' : ['color management supported:', true]}, section : 'Configuration', bool_yn : true)
+        else
+            summary({'cms' : ['lcms2' + req_version + ' not found - color management supported:', false]}, section : 'Configuration', bool_yn : true)
+        endif
     else
-        summary({'cms' : ['lcms2' + req_version + ' not found - color management supported:', false]}, section : 'Configuration', bool_yn : true)
+        summary({'cms' : ['xxd or xxdi.pl not found - color management supported:', false]}, section : 'Configuration', bool_yn : true)
     endif
 else
     summary({'cms' : ['disabled - color management supported:', false]}, section : 'Configuration', bool_yn : true)
@@ -195,6 +250,32 @@ else
     summary({'djvu' : ['disabled - djvu files supported:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
+option = get_option('evince')
+if not option.disabled()
+    evince = find_program('evince', required : false)
+    if evince.found()
+        summary({'print preview' : ['print preview supported:', true]}, section : 'Configuration', bool_yn : true)
+    else
+        summary({'print preview' : ['evince not found - print preview supported:', false]}, section : 'Configuration', bool_yn : true)
+    endif
+else
+    summary({'print preview' : ['disabled - print preview supported:', false]}, section : 'Configuration', bool_yn : true)
+endif
+
+# Required only for seg. fault stacktrace and backtrace debugging
+option = get_option('execinfo')
+if not option.disabled()
+    result = cc.check_header('execinfo.h')
+    if result
+        conf_data.set('HAVE_EXECINFO_H', 1)
+        summary({'execinfo' : ['stacktrace supported:', true]}, section : 'Configuration', bool_yn : true)
+    else
+        summary({'execinfo' : ['stacktrace supported:', false]}, section : 'Configuration', bool_yn : true)
+    endif
+else
+    summary({'execinfo' : ['stacktrace supported:', false]}, section : 'Configuration', bool_yn : true)
+endif
+
 exiv2_dep = []
 req_version = '>=0.11'
 option = get_option('exiv2')
@@ -210,42 +291,6 @@ else
     summary({'exiv2' : ['disabled - image data processed by exiv2:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
-libffmpegthumbnailer_dep = []
-req_version = '>=2.1.0'
-option = get_option('videothumbnailer')
-if not option.disabled()
-    libffmpegthumbnailer_dep = dependency('libffmpegthumbnailer',
-        version : req_version,
-        required : get_option('videothumbnailer'))
-
-    if libffmpegthumbnailer_dep.found()
-        conf_data.set('HAVE_FFMPEGTHUMBNAILER', 1)
-        summary({'videothumbnailer' : ['thumbnails of video files supported:', true]}, section : 'Configuration', bool_yn : true)
-
-        result = cc.has_member('struct video_thumbnailer_struct', 'prefer_embedded_metadata', prefix : '#include <libffmpegthumbnailer/videothumbnailerc.h>')
-        if result
-            conf_data.set('HAVE_FFMPEGTHUMBNAILER_METADATA', 1)
-        endif
-        summary({'fmpegthumbnailer_metadata' : ['fmpegthumbnailer_metadata found:', result]}, section : 'Thumbnailer', bool_yn : true)
-
-        result = cc.has_member('struct image_data_struct', 'image_data_width', prefix : '#include <libffmpegthumbnailer/videothumbnailerc.h>' )
-        if result
-            conf_data.set('HAVE_FFMPEGTHUMBNAILER_RGB', 1)
-        endif
-        summary({'fmpegthumbnailer_rgb' : ['fmpegthumbnailer_rgb found:', result]}, section : 'Thumbnailer', bool_yn : true)
-
-        result = cc.has_function('video_thumbnailer_set_size', dependencies : libffmpegthumbnailer_dep)
-        if result
-            conf_data.set('HAVE_FFMPEGTHUMBNAILER_WH', 1)
-        endif
-        summary({'fmpegthumbnailer_set_size' : ['fmpegthumbnailer_set_size found:', result]}, section : 'Thumbnailer', bool_yn : true)
-    else
-        summary({'videothumbnailer' : ['libvideothumbnailer ' + req_version + ' not found - thumbnails of video files supported', false]}, section : 'Configuration', bool_yn : true)
-    endif
-else
-    summary({'videothumbnailer' : ['disabled -thumbnails of video files supported', false]}, section : 'Configuration', bool_yn : true)
-endif
-
 champlain_dep = []
 champlain_gtk_dep = []
 clutter_dep = []
@@ -384,6 +429,27 @@ else
     summary({'lua' : ['disabled - lua supported:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
+option = get_option('pandoc')
+if not option.disabled()
+    pandoc = find_program('pandoc', required : false)
+    if pandoc.found()
+        readme_html = custom_target(
+            'README.html',
+            input: 'README.md',
+            output: 'README.html',
+            command: [pandoc, '@INPUT@', '-o', '@OUTPUT@'],
+            install: true,
+            install_dir: helpdir)
+
+        summary({'README' : ['README.html created:', true]}, section : 'Documentation', bool_yn : true)
+    else
+        summary({'README' : ['pandoc not found - README.html created:', false]}, section : 'Documentation', bool_yn : true)
+    endif
+    install_data('README.md', 'COPYING', 'TODO', install_dir : helpdir)
+else
+    summary({'pandoc' : ['disabled - README.html created:', false]}, section : 'Documentation', bool_yn : true)
+endif
+
 poppler_glib_dep = []
 req_version = '>=0.62'
 option = get_option('pdf')
@@ -408,10 +474,10 @@ if not option.disabled()
         conf_data.set('HAVE_SPELL', 1)
         summary({'spell' : ['spelling checks enabled', true]}, section : 'Configuration', bool_yn : true)
     else
-        summary({'spell' : ['gspell-1 ' + req_version + ' not found - spelling checks not enabled', false]}, section : 'Configuration', bool_yn : true)
+        summary({'spell' : ['gspell-1 ' + req_version + ' not found - spelling checks enabled', false]}, section : 'Configuration', bool_yn : true)
     endif
 else
-    summary({'spell' : ['disabled - spelling checks not enabled', false]}, section : 'Configuration', bool_yn : true)
+    summary({'spell' : ['disabled - spelling checks enabled', false]}, section : 'Configuration', bool_yn : true)
 endif
 
 tiff_dep = []
@@ -432,19 +498,55 @@ else
     summary({'tiff' : ['disabled - tiff files supported:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
-libwebp_dep = []
-req_version = '>=0.6.1'
-option = get_option('webp')
+libffmpegthumbnailer_dep = []
+req_version = '>=2.1.0'
+option = get_option('videothumbnailer')
 if not option.disabled()
-    libwebp_dep = dependency('libwebp', version : req_version, required : get_option('webp'))
+    libffmpegthumbnailer_dep = dependency('libffmpegthumbnailer',
+        version : req_version,
+        required : get_option('videothumbnailer'))
+
+    if libffmpegthumbnailer_dep.found()
+        conf_data.set('HAVE_FFMPEGTHUMBNAILER', 1)
+        summary({'videothumbnailer' : ['thumbnails of video files supported:', true]}, section : 'Configuration', bool_yn : true)
+
+        result = cc.has_member('struct video_thumbnailer_struct', 'prefer_embedded_metadata', prefix : '#include <libffmpegthumbnailer/videothumbnailerc.h>')
+        if result
+            conf_data.set('HAVE_FFMPEGTHUMBNAILER_METADATA', 1)
+        endif
+        summary({'fmpegthumbnailer_metadata' : ['fmpegthumbnailer_metadata found:', result]}, section : 'Thumbnailer', bool_yn : true)
+
+        result = cc.has_member('struct image_data_struct', 'image_data_width', prefix : '#include <libffmpegthumbnailer/videothumbnailerc.h>' )
+        if result
+            conf_data.set('HAVE_FFMPEGTHUMBNAILER_RGB', 1)
+        endif
+        summary({'fmpegthumbnailer_rgb' : ['fmpegthumbnailer_rgb found:', result]}, section : 'Thumbnailer', bool_yn : true)
+
+        result = cc.has_function('video_thumbnailer_set_size', dependencies : libffmpegthumbnailer_dep)
+        if result
+            conf_data.set('HAVE_FFMPEGTHUMBNAILER_WH', 1)
+        endif
+        summary({'fmpegthumbnailer_set_size' : ['fmpegthumbnailer_set_size found:', result]}, section : 'Thumbnailer', bool_yn : true)
+    else
+        summary({'videothumbnailer' : ['libvideothumbnailer ' + req_version + ' not found - thumbnails of video files supported', false]}, section : 'Configuration', bool_yn : true)
+    endif
+else
+    summary({'videothumbnailer' : ['disabled -thumbnails of video files supported', false]}, section : 'Configuration', bool_yn : true)
+endif
+
+# libpixbufloader-webp is not loaded as part of libgdk-pixbuf. Just issue
+# a warning if not installed
+libwebp_dir = dependency('gdk-pixbuf-2.0', method: 'pkg-config').get_variable(pkgconfig: 'gdk_pixbuf_moduledir', internal: 'gdk_pixbuf_moduledir')
+
+if libwebp_dir.contains('loaders')
+    libwebp_dep = cc.find_library('pixbufloader-webp', dirs : libwebp_dir, required : false)
     if libwebp_dep.found()
-        conf_data.set('HAVE_WEBP', 1)
         summary({'webp' : ['webp files supported:', true]}, section : 'Configuration', bool_yn : true)
     else
-        summary({'webp' : ['libwebp ' + req_version + ' not found - webp files supported:', false]}, section : 'Configuration', bool_yn : true)
+        summary({'webp' : ['webp-pixbuf-loader not installed - webp files supported:', false]}, section : 'Configuration', bool_yn : true)
     endif
 else
-    summary({'webp' : ['disabled - webp files supported:', false]}, section : 'Configuration', bool_yn : true)
+    summary({'webp' : ['webp-pixbuf-loader not installed - webp files supported:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
 # Check for nl_langinfo and _NL_TIME_FIRST_WEEKDAY
@@ -462,11 +564,6 @@ else
     summary({'nl_langinfo' : ['nl_langinfo not found - first weekday depends on locale:', false, 'first weekday defaults to Monday']}, section : 'Documentation', bool_yn : true)
 endif
 
-result = cc.has_function('strverscmp', prefix : '#include <string.h>')
-if result
-    conf_data.set('HAVE_STRVERSCMP', 1)
-endif
-
 conf_data.set_quoted('GETTEXT_PACKAGE', meson.project_name())
 conf_data.set_quoted('GQ_APPDIR', gq_appdir)
 conf_data.set_quoted('GQ_BINDIR', gq_bindir)
@@ -511,32 +608,6 @@ if running_from_git
 elif fs.exists('ChangeLog.html')
     install_data('ChangeLog', 'ChangeLog.html', install_dir: helpdir)
     summary({'ChangeLog' : ['ChangeLog, ChangeLog.html installed from dist:', true]}, section : 'Documentation', bool_yn : true)
-else
-    summary({'ChangeLog' : ['ChangeLog, ChangeLog.html created:', false]}, section : 'Documentation', bool_yn : true)
-endif
-
-pandoc = find_program('pandoc', required : false)
-if pandoc.found()
-    readme_html = custom_target(
-        'README.html',
-        input: 'README.md',
-        output: 'README.html',
-        command: [pandoc, '@INPUT@', '-o', '@OUTPUT@'],
-        install: true,
-        install_dir: helpdir)
-
-    summary({'README' : ['README.html created:', true]}, section : 'Documentation', bool_yn : true)
-else
-    summary({'README' : ['pandoc not found - README.html created:', false]}, section : 'Documentation', bool_yn : true)
-endif
-install_data('README.md', 'COPYING', 'TODO', 'AUTHORS',
-             install_dir : helpdir)
-
-evince = find_program('evince', required : false)
-if evince.found()
-    summary({'print preview' : ['print preview supported:', true]}, section : 'Documentation', bool_yn : true)
-else
-    summary({'print preview' : ['evince not found - print preview supported:', false]}, section : 'Documentation', bool_yn : true)
 endif
 
 install_data('geeqie.png', install_dir : icondir)
@@ -559,3 +630,13 @@ i18n.merge_file(
     install_dir : appdatadir)
 
 configure_file(input: 'geeqie.spec.in', output: 'geeqie.spec', configuration: conf_data)
+
+# Basic test of the executable
+xvfb = find_program('xvfb-run', required : false)
+if xvfb.found()
+    test('Basic test', xvfb, args: ['--auto-servernum', geeqie_exe, '--version'], timeout: 100)
+    summary({'xvfb' : ['Test runs:', true]}, section : 'Debugging', bool_yn : true)
+else
+    summary({'xvfb' : ['Test runs:', false]}, section : 'Debugging', bool_yn : true)
+
+endif