[pangomm] Meson build: Make it possible to use pangomm as a subproject



commit 29ef80574d7ce99c340b6eebdd513113809101c7
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Tue Mar 16 15:05:47 2021 +0100

    Meson build: Make it possible to use pangomm as a subproject
    
    pango, cairomm and glibmm can be subprojects of pangomm.

 Makefile.am                      |  3 +++
 docs/reference/meson.build       |  8 ++++----
 meson.build                      | 19 +++++++++++++++++--
 pango/pangomm/meson.build        |  6 +++---
 subprojects/cairomm-1.16.wrap    |  8 ++++++++
 subprojects/glibmm-2.68.wrap     |  8 ++++++++
 subprojects/pango.wrap           |  8 ++++++++
 tools/extra_defs_gen/meson.build |  8 +++++++-
 8 files changed, 58 insertions(+), 10 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index f6b6551..21c2b4f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -57,6 +57,9 @@ EXTRA_DIST = \
   pango/meson.build \
   pango/pangomm/meson.build \
   pango/pangommconfig.h.meson \
+  subprojects/cairomm-1.16.wrap \
+  subprojects/glibmm-2.68.wrap \
+  subprojects/pango.wrap \
   tools/dummy-header.py \
   tools/extra_defs_gen/meson.build \
   untracked/README
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
index 6155ec3..bfc85a9 100644
--- a/docs/reference/meson.build
+++ b/docs/reference/meson.build
@@ -3,7 +3,7 @@
 # Input: built_files_root, project_source_root, pangomm_pcname, python3,
 #        hg_ccg_basenames, extra_h_files, built_h_file_targets, install_datadir,
 #        doc_reference_py
-# Output: install_docdir, install_devhelpdir
+# Output: install_docdir, install_devhelpdir, tag_file
 
 tag_file_modules = [
   'mm-common-libstdc++',
@@ -16,9 +16,9 @@ docinstall_flags = []
 foreach module : tag_file_modules
   depmod = dependency(module, required: false)
   if depmod.found()
-    doxytagfile = depmod.get_pkgconfig_variable('doxytagfile')
-    htmlrefpub = depmod.get_pkgconfig_variable('htmlrefpub', default: '')
-    htmlrefdir = depmod.get_pkgconfig_variable('htmlrefdir', default: '')
+    doxytagfile = depmod.get_variable(pkgconfig: 'doxytagfile', internal: 'doxytagfile')
+    htmlrefpub = depmod.get_variable(pkgconfig: 'htmlrefpub', internal: 'htmlrefpub', default_value: '')
+    htmlrefdir = depmod.get_variable(pkgconfig: 'htmlrefdir', internal: 'htmlrefdir', default_value: '')
     if htmlrefpub == ''
       htmlrefpub = htmlrefdir
     elif htmlrefdir == ''
diff --git a/meson.build b/meson.build
index 6cdd1d5..e1dba25 100644
--- a/meson.build
+++ b/meson.build
@@ -6,7 +6,8 @@ project('pangomm', 'cpp',
   default_options: [
     'cpp_std=c++17'
   ],
-  meson_version: '>= 0.50.0', # required for python3.path()
+  meson_version: '>= 0.54.0', # required for meson.override_dependency()
+                              # and dep.get_variable(internal:)
 )
 
 pangomm_api_version = '2.48'
@@ -130,7 +131,7 @@ dot = find_program('dot', required: build_documentation) # Used by Doxygen
 xsltproc = find_program('xsltproc', required: build_documentation)
 
 # Where to find gmmproc and generate_wrap_init.pl.
-gmmproc_dir = glibmm_dep.get_pkgconfig_variable('gmmprocdir')
+gmmproc_dir = glibmm_dep.get_variable(pkgconfig: 'gmmprocdir', internal: 'gmmprocdir')
 
 # Script files copied to 'untracked' by mm-common-get.
 script_dir = project_source_root / 'untracked' / 'build_scripts'
@@ -237,6 +238,20 @@ if not meson.is_subproject()
     project_source_root,
     'untracked' / 'build_scripts',
   )
+else
+  # This is a subproject.
+  pangomm_dep = declare_dependency(
+    dependencies: pangomm_own_dep,
+    variables: {
+      'gmmprocm4dir': project_source_root / 'tools' / 'm4',
+      'doxytagfile': tag_file.full_path(),
+      'htmlrefdir': install_prefix / install_docdir / 'reference' / 'html',
+      'htmlrefpub': 'http://library.gnome.org/devel/' + pkg_conf_data.get_unquoted('PACKAGE_TARNAME') + 
'/unstable/'
+    }
+  )
+
+  # A main project that looks for pangomm_pcname.pc shall find pangomm_dep.
+  meson.override_dependency(pangomm_pcname, pangomm_dep)
 endif
 
 # Print a summary.
diff --git a/pango/pangomm/meson.build b/pango/pangomm/meson.build
index 0910d2d..172cb14 100644
--- a/pango/pangomm/meson.build
+++ b/pango/pangomm/meson.build
@@ -4,7 +4,7 @@
 #        generate_binding_py, m4_files, pangomm_libversion, install_includedir,
 #        python3, pangomm_rc, dummy_header_py, gmmproc_dir, msvc14x_toolset_ver
 # Output: hg_ccg_basenames, extra_h_files, built_h_file_targets, built_files_root,
-#         pangomm_dep
+#         pangomm_own_dep
 
 defs_basefiles = [
   'pango.defs',
@@ -231,9 +231,9 @@ if not meson.is_subproject()
   )
 endif
 
-# This is useful in the main project when pangomm is used as a subproject.
+# This is part of pangomm_dep, when pangomm is a subproject.
 # It can also be used if there are example programs and test programs to build.
-pangomm_dep = declare_dependency(
+pangomm_own_dep = declare_dependency(
   sources: built_h_file_targets,
   link_with: pangomm_library,
   include_directories: extra_include_dirs,
diff --git a/subprojects/cairomm-1.16.wrap b/subprojects/cairomm-1.16.wrap
new file mode 100644
index 0000000..12f8821
--- /dev/null
+++ b/subprojects/cairomm-1.16.wrap
@@ -0,0 +1,8 @@
+[wrap-git]
+directory=cairomm
+url=https://gitlab.freedesktop.org/cairo/cairomm.git
+revision=master
+depth=1
+
+[provide]
+dependency_names = cairomm-1.16
diff --git a/subprojects/glibmm-2.68.wrap b/subprojects/glibmm-2.68.wrap
new file mode 100644
index 0000000..a0fef48
--- /dev/null
+++ b/subprojects/glibmm-2.68.wrap
@@ -0,0 +1,8 @@
+[wrap-git]
+directory=glibmm
+url=https://gitlab.gnome.org/GNOME/glibmm.git
+revision=master
+depth=1
+
+[provide]
+dependency_names = glibmm-2.68, giomm-2.68
diff --git a/subprojects/pango.wrap b/subprojects/pango.wrap
new file mode 100644
index 0000000..d90d791
--- /dev/null
+++ b/subprojects/pango.wrap
@@ -0,0 +1,8 @@
+[wrap-git]
+directory=pango
+url=https://gitlab.gnome.org/GNOME/pango.git
+revision=master
+depth=1
+
+[provide]
+dependency_names = pango, pangocairo
diff --git a/tools/extra_defs_gen/meson.build b/tools/extra_defs_gen/meson.build
index 308235e..a7c4fc4 100644
--- a/tools/extra_defs_gen/meson.build
+++ b/tools/extra_defs_gen/meson.build
@@ -1,12 +1,18 @@
 # tools/extra_defs_gen
 
 # Input: cpp_compiler, pangomm_build_dep, install_libdir, pangomm_pcname,
-#        msvc14x_toolset_ver
+#        msvc14x_toolset_ver, glibmm_dep
 # Output: m4_files, install_m4dir
 
 glibmm_generate_extra_defs_dep = cpp_compiler.find_library(
   'glibmm_generate_extra_defs@0@-2.68'.format(msvc14x_toolset_ver),
+  required: glibmm_dep.type_name() != 'internal',
 )
+if not glibmm_generate_extra_defs_dep.found()
+  glibmm_generate_extra_defs_dep = dependency(
+    '', fallback: ['glibmm-2.68', 'glibmm_generate_extra_defs_dep'],
+  )
+endif
 
 executable('generate_extra_defs', 'generate_defs_pango.cc',
   dependencies: [pangomm_build_dep, glibmm_generate_extra_defs_dep],


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