Skip to content

Commit ea94a3b

Browse files
committed
Meson build: Make it possible to use sigc++ as a subproject
mm-common can be a subproject of sigc++.
1 parent dc5027b commit ea94a3b

File tree

7 files changed

+37
-14
lines changed

7 files changed

+37
-14
lines changed

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ EXTRA_DIST = \
5454
docs/docs/reference/meson.build \
5555
examples/meson.build \
5656
sigc++/meson.build \
57+
subprojects/mm-common.wrap \
5758
tests/meson.build \
5859
tools/handle-built-files.py \
5960
tools/tutorial-custom-cmd.py \

docs/docs/reference/meson.build

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Input: project_build_root, project_source_root, sigcxx_pcname,
44
# sigcxx_api_version, build_documentation, source_h_files,
55
# hg_ccg_basenames, install_datadir, python3, doc_reference
6-
# Output: install_docdir, install_devhelpdir, book_name
6+
# Output: install_docdir, install_devhelpdir, book_name, tag_file
77

88
# There are no built source files in libsigc++-3.0.
99

@@ -15,9 +15,9 @@ docinstall_flags = []
1515
foreach module : tag_file_modules
1616
depmod = dependency(module, required: false)
1717
if depmod.found()
18-
doxytagfile = depmod.get_pkgconfig_variable('doxytagfile')
19-
htmlrefpub = depmod.get_pkgconfig_variable('htmlrefpub', default: '')
20-
htmlrefdir = depmod.get_pkgconfig_variable('htmlrefdir', default: '')
18+
doxytagfile = depmod.get_variable(pkgconfig: 'doxytagfile', internal: 'doxytagfile')
19+
htmlrefpub = depmod.get_variable(pkgconfig: 'htmlrefpub', internal: 'htmlrefpub', default_value: '')
20+
htmlrefdir = depmod.get_variable(pkgconfig: 'htmlrefdir', internal: 'htmlrefdir', default_value: '')
2121
if htmlrefpub == ''
2222
htmlrefpub = htmlrefdir
2323
elif htmlrefdir == ''

examples/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# examples
22

3-
# input: sigcxx_dep, build_examples
3+
# input: sigcxx_own_dep, build_examples
44

55
examples = [
66
# [[dir-name], exe-name, [sources]]
@@ -21,7 +21,7 @@ foreach ex : examples
2121

2222
exe_file = executable(ex_name, ex_sources,
2323
cpp_args: '-DSIGCXX_DISABLE_DEPRECATED',
24-
dependencies: sigcxx_dep,
24+
dependencies: sigcxx_own_dep,
2525
gui_app: false,
2626
build_by_default: build_examples
2727
)

meson.build

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ project('libsigc++', 'cpp',
77
'cpp_std=c++17',
88
'warning_level=0',
99
],
10-
meson_version: '>= 0.50.0', # required for python3.path()
10+
meson_version: '>= 0.54.0', # required for dep.get_variable(internal:)
1111
)
1212

1313
sigcxx_api_version = '3.0'
@@ -238,6 +238,19 @@ if not meson.is_subproject()
238238
project_source_root,
239239
'untracked' / 'build_scripts',
240240
)
241+
else
242+
# This is a subproject.
243+
sigcxx_dep = declare_dependency(
244+
dependencies: sigcxx_own_dep,
245+
variables: {
246+
'doxytagfile': tag_file.full_path(),
247+
'htmlrefdir': install_prefix / install_docdir / 'reference' / 'html',
248+
'htmlrefpub': 'http://library.gnome.org/devel/libsigc++/unstable/'
249+
}
250+
)
251+
252+
# A main project that looks for sigcxx_pcname.pc shall find sigcxx_dep.
253+
meson.override_dependency(sigcxx_pcname, sigcxx_dep)
241254
endif
242255

243256
# Print a summary.

sigc++/meson.build

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Input: sigcxx_build_dep, sigcxx_pcname, sigcxx_libversion, sigcxx_api_version,
44
# darwin_versions, install_includedir, sig_rc
5-
# Output: source_h_files, sigcxx_dep
5+
# Output: source_h_files, sigcxx_own_dep
66

77
# There are no built source files in libsigc++-3.0.
88

@@ -96,9 +96,9 @@ sigcxx_library = library('sigc-' + sigcxx_api_version,
9696
install: true,
9797
)
9898

99-
# This is useful in the main project when libsigc++ is used as a subproject.
100-
# It's also used when building example programs and test programs.
101-
sigcxx_dep = declare_dependency(
99+
# This is used when building example programs and test programs.
100+
# It's also a part of sigcxx_dep, when libsigc++ is a subproject.
101+
sigcxx_own_dep = declare_dependency(
102102
link_with: sigcxx_library,
103103
include_directories: extra_include_dirs,
104104
dependencies: sigcxx_build_dep

subprojects/mm-common.wrap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[wrap-git]
2+
directory=mm-common
3+
url=https://gitlab.gnome.org/GNOME/mm-common.git
4+
revision=master
5+
depth=1
6+
7+
[provide]
8+
dependency_names = mm-common-libstdc++
9+
program_names = mm-common-get

tests/meson.build

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# tests
22

3-
# input: sigcxx_dep, do_benchmark, can_benchmark, benchmark_dep
3+
# input: sigcxx_own_dep, do_benchmark, can_benchmark, benchmark_dep
44

55
benchmark_timeout = 100
66

@@ -64,7 +64,7 @@ foreach ex : test_programs
6464
endforeach
6565

6666
exe_file = executable(ex_name, ex_sources,
67-
dependencies: sigcxx_dep,
67+
dependencies: sigcxx_own_dep,
6868
gui_app: false,
6969
build_by_default: true
7070
)
@@ -85,7 +85,7 @@ if can_benchmark
8585
endforeach
8686

8787
exe_file = executable(ex_name, ex_sources,
88-
dependencies: [sigcxx_dep, benchmark_dep],
88+
dependencies: [sigcxx_own_dep, benchmark_dep],
8989
gui_app: false,
9090
build_by_default: do_benchmark
9191
)

0 commit comments

Comments
 (0)