[gtkmm-documentation/gtkmm-3-24] Meson build: Don't require gtkmm unconditionally



commit 3ddf8684cfca770d0a3c6e988bbd7c58a17ecc38
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Sun Dec 27 13:32:15 2020 +0100

    Meson build: Don't require gtkmm unconditionally
    
    Require gtkmm and giomm only if build-examples=true
    or a tarball is being built.

 examples/meson.build | 23 ++++++++++++-----------
 meson.build          | 21 ++++++++++++++++++---
 2 files changed, 30 insertions(+), 14 deletions(-)
---
diff --git a/examples/meson.build b/examples/meson.build
index 6a90079..b783cfa 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -1,19 +1,20 @@
 # examples
 
-# input: gnome, gtkmm_dep, giomm_dep, compile_schemas, copy_to_subdir,
-#        project_build_root, python3
-# output: build_examples_by_default
+# input: gnome, gtkmm_dep, giomm_dep, compile_schemas, copy_to_subdir, python3,
+#        project_build_root, build_examples_by_default, can_build_examples
+# output: -
 
-# examples/book/input/main.cc must know if mkfifo() exists.
-has_mkfifo = cpp_compiler.has_function('mkfifo')
-
-meson_backend = find_program(meson.backend(), required: true)
-build_examples_by_default = get_option('build-examples')
-test_timeout = 80 # max seconds per test
 examples_targets = []
 
-subdir('book')
-subdir('others')
+if can_build_examples
+  # examples/book/input/main.cc must know if mkfifo() exists.
+  has_mkfifo = cpp_compiler.has_function('mkfifo')
+
+  meson_backend = find_program(meson.backend(), required: true)
+  test_timeout = 80 # max seconds per test
+  subdir('book')
+  subdir('others')
+endif
 
 # 'ninja examples' builds all example programs.
 # alias_target(), added in Meson 0.52.0, is an alternative to run_target().
diff --git a/meson.build b/meson.build
index 95d8592..cd74153 100644
--- a/meson.build
+++ b/meson.build
@@ -17,8 +17,9 @@ if not python_version.version_compare(python_version_req)
 endif
 
 gtkmm_pcname = 'gtkmm-3.0'
-gtkmm_dep = dependency(gtkmm_pcname, version: '>=3.24.0')
-giomm_dep = dependency('giomm-2.4', version: '>=2.54.0')
+gtkmm_req = '>= 3.24.0'
+giomm_pcname = 'giomm-2.4'
+giomm_req = '>= 2.54.0'
 gnome = import('gnome')
 
 # Installation directories are relative to {prefix}.
@@ -43,6 +44,8 @@ cpp_compiler = meson.get_compiler('cpp')
 is_dist_check = project_source_root.contains('dist-unpack') and \
                 project_build_root.contains('dist-build')
 
+# Options
+build_examples_by_default = get_option('build-examples')
 if is_dist_check
   message('Looks like a tarball is being tested. ' + \
           'Option "dist-warnings" is used instead of "warnings".')
@@ -51,6 +54,12 @@ else
   warning_level = get_option('warnings')
 endif
 
+must_be_able_to_build_examples = build_examples_by_default or is_dist_check
+
+gtkmm_dep = dependency(gtkmm_pcname, version: gtkmm_req, required: must_be_able_to_build_examples)
+giomm_dep = dependency(giomm_pcname, version: giomm_req, required: must_be_able_to_build_examples)
+can_build_examples = gtkmm_dep.found() and giomm_dep.found()
+
 warning_flags = []
 if warning_level == 'min'
   warning_flags = ['-Wall']
@@ -88,6 +97,12 @@ if not meson.is_subproject()
 endif
 
 # Print a summary.
+explain_ex = ''
+if not can_build_examples
+  explain_ex = ' (requires @0@ @1@ and @2@ @3@)'
+  explain_ex = explain_ex.format(gtkmm_pcname, gtkmm_req, giomm_pcname, giomm_req)
+endif
+
 validate = get_option('validation') and can_parse_and_validate
 explain_val = ''
 if get_option('validation') and not validate
@@ -111,7 +126,7 @@ summary = [
   '------',
   meson.project_name() + ' ' + meson.project_version(),
   '',
-  '    Build examples: @0@'.format(build_examples_by_default),
+  '    Build examples: @0@@1@'.format(build_examples_by_default, explain_ex),
   ' Compiler warnings: @0@'.format(warning_level),
   '    XML validation: @0@@1@'.format(validate, explain_val),
   'Build translations: @0@@1@'.format(build_translations, explain_trans),


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