[atkmm/atkmm-2-28] Meson build: Make it possible to use atkmm as a subproject



commit 99b71c8531d8135dd62cfa283305e91576fd96e4
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Fri Mar 26 15:56:25 2021 +0100

    Meson build: Make it possible to use atkmm as a subproject
    
    atk and glibmm can be subprojects of atkmm.

 Makefile.am                   |  2 ++
 atk/atkmm/meson.build         |  9 ++++++---
 codegen/extradefs/meson.build |  8 +++++++-
 doc/reference/meson.build     |  8 ++++----
 meson.build                   | 20 ++++++++++++++++++--
 subprojects/atk.wrap          |  8 ++++++++
 subprojects/glibmm-2.4.wrap   |  8 ++++++++
 7 files changed, 53 insertions(+), 10 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index afca90d..82f24ba 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -61,6 +61,8 @@ EXTRA_DIST = \
   atk/atkmmconfig.h.meson \
   codegen/dummy-header.py \
   codegen/extradefs/meson.build \
+  subprojects/atk.wrap \
+  subprojects/glibmm-2.4.wrap \
   untracked/README
 
 # Auto-generate the ChangeLog file from the git log on make dist
diff --git a/atk/atkmm/meson.build b/atk/atkmm/meson.build
index 0f35091..5a9f28c 100644
--- a/atk/atkmm/meson.build
+++ b/atk/atkmm/meson.build
@@ -5,7 +5,7 @@
 #        python3, atkmm_rc, dummy_header_py, gmmproc_dir, build_shared_libs_directly,
 #        msvc14x_toolset_ver, macos_darwin_versions
 # Output: hg_ccg_basenames, extra_h_files, built_h_file_targets, built_files_root,
-#         atkmm_dep
+#         atkmm_own_dep
 
 defs_basefiles = [
   'atk.defs',
@@ -199,6 +199,7 @@ atkmm_libname = meson.project_name() + msvc14x_toolset_ver + '-' + atkmm_api_ver
 if build_shared_libs_directly
   atkmm_library = library(atkmm_libname, extra_atkmm_objects,
     atk_gen_sources, built_dummy_h_file_target, extra_cc_files,
+    implicit_include_directories: false,
     include_directories: extra_include_dirs,
     cpp_args: atkmm_cpp_args,
     version: atkmm_libversion,
@@ -213,6 +214,7 @@ else
   # needed for obtaining the .lib file for the atkmm DLL
   atk_int_lib = static_library('atkmm-int',
     atk_gen_sources, built_dummy_h_file_target, extra_cc_files,
+    implicit_include_directories: false,
     include_directories: extra_include_dirs,
     cpp_args: atkmm_cpp_args,
     dependencies: atkmm_build_dep,
@@ -235,6 +237,7 @@ else
     objects: atk_int_lib.extract_all_objects(),
     version: atkmm_libversion,
     darwin_versions: macos_darwin_versions,
+    implicit_include_directories: false,
     dependencies: atkmm_build_dep,
     link_depends: atkmm_def,
     link_args: atkmm_extra_link_args,
@@ -261,9 +264,9 @@ if not meson.is_subproject()
   )
 endif
 
-# This is useful in the main project when atkmm is used as a subproject.
+# This is part of atkmm_dep, when atkmm is a subproject.
 # It can also be used if there are example programs and test programs to build.
-atkmm_dep = declare_dependency(
+atkmm_own_dep = declare_dependency(
   sources: built_h_file_targets,
   link_with: atkmm_library,
   include_directories: extra_include_dirs,
diff --git a/codegen/extradefs/meson.build b/codegen/extradefs/meson.build
index de68b9a..6963585 100644
--- a/codegen/extradefs/meson.build
+++ b/codegen/extradefs/meson.build
@@ -1,12 +1,18 @@
 # codegen/extradefs
 
 # Input: cpp_compiler, atkmm_build_dep, install_libdir, atkmm_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.4'.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.4', 'glibmm_generate_extra_defs_dep'],
+  )
+endif
 
 executable('generate_extra_defs', 'generate_extra_defs_atk.cc',
   dependencies: [atkmm_build_dep, glibmm_generate_extra_defs_dep],
diff --git a/doc/reference/meson.build b/doc/reference/meson.build
index 3252622..7ed37c4 100644
--- a/doc/reference/meson.build
+++ b/doc/reference/meson.build
@@ -3,7 +3,7 @@
 # Input: built_files_root, project_source_root, atkmm_pcname, hg_ccg_basenames,
 #        extra_h_files, built_h_file_targets, install_datadir, python3,
 #        doc_reference_py
-# Output: install_docdir, install_devhelpdir
+# Output: install_docdir, install_devhelpdir, tag_file
 
 tag_file_modules = [
   'mm-common-libstdc++',
@@ -15,9 +15,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 6dd6970..9e3f780 100644
--- a/meson.build
+++ b/meson.build
@@ -6,7 +6,8 @@ project('atkmm', 'cpp',
   default_options: [
     'cpp_std=c++11'
   ],
-  meson_version: '>= 0.50.0', # required for python3.path()
+  meson_version: '>= 0.54.0', # required for meson.override_dependency()
+                              # and dep.get_variable(internal:)
 )
 
 atkmm_api_version = '1.6'
@@ -107,7 +108,8 @@ glibmm_req_minor_ver = '4'
 
 glibmm_dep = dependency('glibmm-2.@0@'.format(glibmm_req_minor_ver), version: glibmm_req)
 
-gmmproc_dir = glibmm_dep.get_pkgconfig_variable('gmmprocdir')
+# Where to find gmmproc and generate_wrap_init.pl.
+gmmproc_dir = glibmm_dep.get_variable(pkgconfig: 'gmmprocdir', internal: 'gmmprocdir')
 
 if is_msvc
   # Check whether we compile atkmm without using gendef
@@ -266,6 +268,20 @@ if not meson.is_subproject()
     project_source_root,
     'untracked' / 'build_scripts',
   )
+else
+  # This is a subproject.
+  atkmm_dep = declare_dependency(
+    dependencies: atkmm_own_dep,
+    variables: {
+      'gmmprocm4dir': project_source_root / 'codegen' / '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 atkmm_pcname.pc shall find atkmm_dep.
+  meson.override_dependency(atkmm_pcname, atkmm_dep)
 endif
 
 # Print a summary.
diff --git a/subprojects/atk.wrap b/subprojects/atk.wrap
new file mode 100644
index 0000000..8ac8659
--- /dev/null
+++ b/subprojects/atk.wrap
@@ -0,0 +1,8 @@
+[wrap-git]
+directory=atk
+url=https://gitlab.gnome.org/GNOME/atk.git
+revision=master
+depth=1
+
+[provide]
+atk = libatk_dep
diff --git a/subprojects/glibmm-2.4.wrap b/subprojects/glibmm-2.4.wrap
new file mode 100644
index 0000000..a7f7855
--- /dev/null
+++ b/subprojects/glibmm-2.4.wrap
@@ -0,0 +1,8 @@
+[wrap-git]
+directory=glibmm-2.4
+url=https://gitlab.gnome.org/GNOME/glibmm.git
+revision=glibmm-2-66
+depth=1
+
+[provide]
+dependency_names = glibmm-2.4, giomm-2.4


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