Skip to content

Commit

Permalink
Meson build: Make it possible to use gtkmm as a subproject
Browse files Browse the repository at this point in the history
gtk, gdk-pixbuf, epoxy, cairomm, pangomm and glibmm can be
subprojects of gtkmm. See MR !62
  • Loading branch information
kjellahl committed Mar 16, 2021
1 parent 86685b6 commit 94df41a
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 18 deletions.
6 changes: 6 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 2 additions & 2 deletions demos/gtk-demo/meson.build
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions docs/reference/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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++',
Expand All @@ -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 == ''
Expand Down
8 changes: 4 additions & 4 deletions gtk/gtkmm/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down
32 changes: 27 additions & 5 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 = [
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions subprojects/cairomm-1.16.wrap
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions subprojects/gdk-pixbuf.wrap
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions subprojects/glibmm-2.68.wrap
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions subprojects/gtk4.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[wrap-git]
directory=gtk
url=https://gitlab.gnome.org/GNOME/gtk.git
revision=master
depth=1

[provide]
gtk4 = libgtk_dep
8 changes: 8 additions & 0 deletions subprojects/libepoxy.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[wrap-git]
directory=libepoxy
url=https://github.com/anholt/libepoxy.git
revision=master
depth=1

[provide]
epoxy = libepoxy_dep
8 changes: 8 additions & 0 deletions subprojects/pangomm-2.48.wrap
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions tests/meson.build
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down Expand Up @@ -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 : [],
Expand Down
8 changes: 7 additions & 1 deletion tools/extra_defs_gen/meson.build
Original file line number Diff line number Diff line change
@@ -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@[email protected]'.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],
Expand Down

0 comments on commit 94df41a

Please sign in to comment.