[dia: 46/105] #19: Check for optional dependencies in top meson.build.



commit f501792f2681ea01f8a742b9de708ed20208c537
Author: Eduard Nicodei <eddnicodei gmail com>
Date:   Tue Jan 1 20:00:32 2019 +0000

    #19: Check for optional dependencies in top meson.build.
    
      - This ensures we list our dependencies in only one location.
      - We can also build config.h before descending into any subdir.

 meson.build                     | 19 +++++++++++++++----
 plug-ins/layout/meson.build     |  4 ----
 plug-ins/pdf/meson.build        |  6 ------
 plug-ins/pdf/pdf.c              |  2 +-
 plug-ins/postscript/meson.build |  2 --
 5 files changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/meson.build b/meson.build
index 2bd68dd1..4ed8b454 100644
--- a/meson.build
+++ b/meson.build
@@ -10,11 +10,13 @@ project('dia',
 add_global_link_arguments('-lc', language: 'c')
 
 cc = meson.get_compiler('c')
+conf = configuration_data()
 
 #GTK_MODULES="gtk+-2.0 >= 2.16.0 glib-2.0 >= 2.20.0 libxml-2.0 gdk-pixbuf-2.0 gthread-2.0 gmodule-2.0"
 libgtk_dep  = dependency('gtk+-2.0', version : '>= 2.16.0')
 libglib_dep = dependency('glib-2.0', version : '>= 2.20.0')
 libxml_dep  = dependency('libxml-2.0', version : '>= 2.6.27')
+
 #TODO: what are the minimum versions?
 gmodule_dep = dependency('gmodule-2.0')
 libzlib_dep = dependency('zlib')
@@ -23,6 +25,16 @@ libcairo_dep = dependency('cairo')
 libm_dep = cc.find_library('m')
 libc_dep = cc.find_library('c')
 
+# Optional deps
+freetype_dep = dependency('freetype2', version: '>= 11.0.5', required: false)
+conf.set('HAVE_FREETYPE', freetype_dep.found())
+libpoppler_dep = dependency('poppler', version: '<= 0.62.0', required: false)
+conf.set('HAVE_POPPLER', libpoppler_dep.found())
+libogdf_dep = cc.find_library('ogdf', required: false)
+conf.set('HAVE_OGDF', libogdf_dep.found())
+
+
+
 # Used in pixmap csource generation.
 gdk_pixbuf_csource = find_program('gdk-pixbuf-csource')
 
@@ -36,7 +48,6 @@ dialibdir = join_paths(get_option('prefix'),
                        meson.project_name())
 
 # Specify a header configuration file
-conf = configuration_data()
 conf.set_quoted('VERSION', meson.project_version())
 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
 conf.set_quoted('DATADIR', datadir)
@@ -45,6 +56,7 @@ conf.set_quoted('DIALIBDIR',  dialibdir)
 conf.set_quoted('LOCALEDIR', get_option('localedir'))
 conf.set('ENABLE_NLS', 1)
 
+
 foreach h : ['stddef.h', 'fcntl.h', 'unistd.h', 'utime.h']
     conf.set10('HAVE_' + h.underscorify().to_upper(), cc.has_header(h))
 endforeach
@@ -54,6 +66,8 @@ foreach f : ['select', 'strcspn', 'strdup', 'strtol']
 endforeach
 
 configuration_inc = include_directories('.')
+configure_file(output : 'config.h',
+               configuration : conf)
 
 # TODO: I don't think this should be defined.
 # To fix we should remove #ifdef HAVE_CONFIG_H checks from all source files.
@@ -69,7 +83,4 @@ subdir('plug-ins')
 subdir('sheets')
 subdir('shapes')
 
-configure_file(output : 'config.h',
-               configuration : conf)
-
 meson.add_install_script('meson-helpers/post-install.py', datadir)
diff --git a/plug-ins/layout/meson.build b/plug-ins/layout/meson.build
index f065ad71..2ea38d3b 100644
--- a/plug-ins/layout/meson.build
+++ b/plug-ins/layout/meson.build
@@ -1,16 +1,12 @@
-
 sources = files(
     'dia-graph.cpp',
     'layout.cpp',
 )
 
-libogdf_dep = cc.find_library('ogdf', required: false)
-
 deps = [libgtk_dep, libm_dep, libxml_dep]
 
 #TODO: this needs to be tested.
 if libogdf_dep.found() == true
-    conf.set('HAVE_OGDF', 1)
     deps += [libogdf_dep]
     sources += ['ogdf-simple.cpp']
 endif
diff --git a/plug-ins/pdf/meson.build b/plug-ins/pdf/meson.build
index 5184a4f1..ff393edd 100644
--- a/plug-ins/pdf/meson.build
+++ b/plug-ins/pdf/meson.build
@@ -1,11 +1,6 @@
 sources = [files('pdf.c')]
 deps = []
 
-libpoppler_dep = dependency('poppler',
-    version: '<= 0.62.0',
-    required: false
-)
-
 # TODO: we should be able to use has_header_symbol.
 # However, that does not seem to pick up on GBool, gTrue etc.
 #has_gTrue = cc.has_header_symbol(
@@ -19,7 +14,6 @@ has_gtypes = cc.has_header(
 )
 
 if libpoppler_dep.found() and has_gtypes
-    conf.set('HAVE_POPPLER', 1)
     sources += [files('pdf-import.cpp')]
     deps += [libpoppler_dep]
 endif
diff --git a/plug-ins/pdf/pdf.c b/plug-ins/pdf/pdf.c
index 34c91513..f7d94f74 100644
--- a/plug-ins/pdf/pdf.c
+++ b/plug-ins/pdf/pdf.c
@@ -38,7 +38,7 @@ static const gchar *pdf_extensions[] = { "pdf", NULL };
 static DiaImportFilter pdf_import_filter = {
     N_("Portable Document File"),
     pdf_extensions,
-#if HAVE_POPPLER
+#ifdef HAVE_POPPLER
     import_pdf,
 #else
     no_import_pdf,
diff --git a/plug-ins/postscript/meson.build b/plug-ins/postscript/meson.build
index f27068e4..87db2728 100644
--- a/plug-ins/postscript/meson.build
+++ b/plug-ins/postscript/meson.build
@@ -7,8 +7,6 @@ sources = files(
 )
 deps = []
 
-# TODO: actual check for freetype lib.
-freetype_dep = dependency('freetype2', version: '>= 11.0.5', required: false)
 if freetype_dep.found()
     sources += files('diapsft2renderer.c')
     deps += [freetype_dep]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]