[gtkmm] Meson build: Make it possible to use gtkmm as a subproject
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Meson build: Make it possible to use gtkmm as a subproject
- Date: Tue, 16 Mar 2021 14:23:36 +0000 (UTC)
commit 94df41a07fdb6b99ab9a1560c9321126d98f34ad
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Tue Mar 16 15:18:58 2021 +0100
Meson build: Make it possible to use gtkmm as a subproject
gtk, gdk-pixbuf, epoxy, cairomm, pangomm and glibmm can be
subprojects of gtkmm. See MR !62
Makefile.am | 6 ++++++
demos/gtk-demo/meson.build | 4 ++--
docs/reference/meson.build | 8 ++++----
gtk/gtkmm/meson.build | 8 ++++----
meson.build | 32 +++++++++++++++++++++++++++-----
subprojects/cairomm-1.16.wrap | 8 ++++++++
subprojects/gdk-pixbuf.wrap | 8 ++++++++
subprojects/glibmm-2.68.wrap | 8 ++++++++
subprojects/gtk4.wrap | 8 ++++++++
subprojects/libepoxy.wrap | 8 ++++++++
subprojects/pangomm-2.48.wrap | 8 ++++++++
tests/meson.build | 4 ++--
tools/extra_defs_gen/meson.build | 8 +++++++-
13 files changed, 100 insertions(+), 18 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 1d8c6069..3ddc9ffb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -69,6 +69,12 @@ EXTRA_DIST = \
gtk/meson.build \
gtk/gtkmmconfig.h.meson \
gtk/gtkmm/meson.build \
+ subprojects/cairomm-1.16.wrap \
+ subprojects/gdk-pixbuf.wrap \
+ subprojects/glibmm-2.68.wrap \
+ subprojects/gtk4.wrap \
+ subprojects/libepoxy.wrap \
+ subprojects/pangomm-2.48.wrap \
tests/meson.build \
tools/dummy-header.py \
tools/extra_defs_gen/meson.build \
diff --git a/demos/gtk-demo/meson.build b/demos/gtk-demo/meson.build
index 9850043d..4645ca01 100644
--- a/demos/gtk-demo/meson.build
+++ b/demos/gtk-demo/meson.build
@@ -1,6 +1,6 @@
# demos/gtk-demo
-# Input: gtkmm_dep, epoxy_dep, build_demos, gui_app_ldflags
+# Input: gtkmm_own_dep, epoxy_dep, build_demos, gui_app_ldflags
# Output: -
gtkmm_demo_cc_files = [
@@ -45,7 +45,7 @@ if epoxy_dep.found()
executable('gtkmm-demo',
gtkmm_demo_cc_files, demo_resources,
- dependencies: [gtkmm_dep, epoxy_dep],
+ dependencies: [gtkmm_own_dep, epoxy_dep],
gui_app: true,
build_by_default: build_demos,
link_args: gui_app_ldflags,
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
index 3e9fc612..0d64c997 100644
--- a/docs/reference/meson.build
+++ b/docs/reference/meson.build
@@ -5,7 +5,7 @@
# gtkmm_extra_h_files, gdkmm_built_h_file_targets,
# gtkmm_built_h_file_targets, install_datadir, python3,
# doc_reference_py, build_documentation
-# Output: install_docdir, install_devhelpdir
+# Output: install_docdir, install_devhelpdir, tag_file
tag_file_modules = [
'mm-common-libstdc++',
@@ -19,9 +19,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/gtk/gtkmm/meson.build b/gtk/gtkmm/meson.build
index 472e6c89..7165316c 100644
--- a/gtk/gtkmm/meson.build
+++ b/gtk/gtkmm/meson.build
@@ -6,7 +6,7 @@
# build_deprecated_api, gmmproc_extra_m4_dirs, is_host_windows,
# gdkmm_library, gdkmm_used_built_h_file_targets, gtkmm_libname
# Output: gtkmm_hg_ccg_basenames, gtkmm_extra_h_files, built_files_root,
-# gtkmm_built_h_file_targets, gtkmm_dep
+# gtkmm_built_h_file_targets, gtkmm_own_dep
gtkmm_defs_basefiles = [
'gtk.defs',
@@ -519,9 +519,9 @@ if not meson.is_subproject()
)
endif
-# This is useful in the main project when gtkmm is used as a subproject.
-# It's also used when building demo programs and test programs.
-gtkmm_dep = declare_dependency(
+# This is used when building demo programs and test programs.
+# It's also a part of gtkmm_dep, when gtkmm is a subproject.
+gtkmm_own_dep = declare_dependency(
sources: gdkmm_used_built_h_file_targets + gtkmm_used_built_h_file_targets,
link_with: gtkmm_library,
include_directories: extra_include_dirs,
diff --git a/meson.build b/meson.build
index 30df67d5..b8d1daed 100644
--- a/meson.build
+++ b/meson.build
@@ -7,7 +7,8 @@ project('gtkmm', 'c', '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:)
)
gtkmm_api_version = '4.0'
@@ -125,9 +126,9 @@ glibmm_dep = dependency('glibmm-2.@0@'.format(glibmm_req_minor_ver), version: gl
giomm_dep = dependency('giomm-2.@0@'.format(glibmm_req_minor_ver), version: glibmm_req)
# 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')
-gmmproc_extra_m4_dirs = [pangomm_dep.get_pkgconfig_variable('gmmprocm4dir')]
+gmmproc_extra_m4_dirs = [pangomm_dep.get_variable(pkgconfig: 'gmmprocm4dir', internal: 'gmmprocm4dir')]
gdkmm_build_dep = [giomm_dep, gtk_dep, cairomm_dep, pangomm_dep, gdk_pixbuf_dep]
gdkmm_requires = [
@@ -143,8 +144,15 @@ gtkmm_requires = gdkmm_requires
# not Windows
if host_machine.system() != 'windows'
- gtk_unix_print_dep = dependency('gtk4-unix-print')
- gtkmm_build_dep += [gtk_unix_print_dep]
+ # gtk4-unix-print consists of only header files (no library).
+ # In gtk's source directory, those header files are stored in the same
+ # directory as other gtk/gtk files. No extra directory need be searched for
+ # header files, when gtk is used uninstalled.
+ gtk_unix_print_dep = dependency('gtk4-unix-print',
+ required: gtk_dep.type_name() != 'internal')
+ if gtk_unix_print_dep.found()
+ gtkmm_build_dep += [gtk_unix_print_dep]
+ endif
gtkmm_requires += ['gtk4-unix-print', '']
endif
@@ -290,6 +298,20 @@ if not meson.is_subproject()
'untracked' / 'build_scripts',
dont_distribute,
)
+else
+ # This is a subproject.
+ gtkmm_dep = declare_dependency(
+ dependencies: gtkmm_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 gtkmm_pcname.pc shall find gtkmm_dep.
+ meson.override_dependency(gtkmm_pcname, gtkmm_dep)
endif
# Print a summary.
diff --git a/subprojects/cairomm-1.16.wrap b/subprojects/cairomm-1.16.wrap
new file mode 100644
index 00000000..12f8821b
--- /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/gdk-pixbuf.wrap b/subprojects/gdk-pixbuf.wrap
new file mode 100644
index 00000000..7d13de8a
--- /dev/null
+++ b/subprojects/gdk-pixbuf.wrap
@@ -0,0 +1,8 @@
+[wrap-git]
+directory=gdk-pixbuf
+url=https://gitlab.gnome.org/GNOME/gdk-pixbuf.git
+revision=master
+depth=1
+
+[provide]
+gdk-pixbuf-2.0 = gdkpixbuf_dep
diff --git a/subprojects/glibmm-2.68.wrap b/subprojects/glibmm-2.68.wrap
new file mode 100644
index 00000000..a0fef481
--- /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/gtk4.wrap b/subprojects/gtk4.wrap
new file mode 100644
index 00000000..66e73ea9
--- /dev/null
+++ b/subprojects/gtk4.wrap
@@ -0,0 +1,8 @@
+[wrap-git]
+directory=gtk
+url=https://gitlab.gnome.org/GNOME/gtk.git
+revision=master
+depth=1
+
+[provide]
+gtk4 = libgtk_dep
diff --git a/subprojects/libepoxy.wrap b/subprojects/libepoxy.wrap
new file mode 100644
index 00000000..ad4f6cb7
--- /dev/null
+++ b/subprojects/libepoxy.wrap
@@ -0,0 +1,8 @@
+[wrap-git]
+directory=libepoxy
+url=https://github.com/anholt/libepoxy.git
+revision=master
+depth=1
+
+[provide]
+epoxy = libepoxy_dep
diff --git a/subprojects/pangomm-2.48.wrap b/subprojects/pangomm-2.48.wrap
new file mode 100644
index 00000000..db433b55
--- /dev/null
+++ b/subprojects/pangomm-2.48.wrap
@@ -0,0 +1,8 @@
+[wrap-git]
+directory=pangomm
+url=https://gitlab.gnome.org/GNOME/pangomm.git
+revision=master
+depth=1
+
+[provide]
+dependency_names = pangomm-2.48
diff --git a/tests/meson.build b/tests/meson.build
index 5bb08722..34fce284 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,6 +1,6 @@
# tests
-# Input: gtkmm_dep, build_tests, gui_app_ldflags
+# Input: gtkmm_own_dep, build_tests, gui_app_ldflags
# Output: -
test_programs = [
@@ -34,7 +34,7 @@ foreach ex : test_programs
endforeach
exe_file = executable(ex_name, ex_sources,
- dependencies: gtkmm_dep,
+ dependencies: gtkmm_own_dep,
gui_app: ex[3],
build_by_default: build_tests,
link_args: ex[3] ? gui_app_ldflags : [],
diff --git a/tools/extra_defs_gen/meson.build b/tools/extra_defs_gen/meson.build
index d8754d8e..e853dee0 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, gdkmm_build_dep, gtkmm_build_dep, install_libdir,
-# gtkmm_pcname, msvc14x_toolset_ver
+# gtkmm_pcname, 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_defs_gdk', 'generate_defs_gdk.cc',
dependencies: [gdkmm_build_dep, glibmm_generate_extra_defs_dep],
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]