Skip to content

Commit 90c17ea

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

File tree

7 files changed

+42
-16
lines changed

7 files changed

+42
-16
lines changed

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ EXTRA_DIST = \
4949
docs/reference/meson.build \
5050
examples/meson.build \
5151
sigc++/meson.build \
52+
subprojects/mm-common.wrap \
5253
tests/meson.build \
5354
tools/handle-built-files.py \
5455
tools/tutorial-custom-cmd.py \

docs/reference/meson.build

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# sigcxx_api_version, build_documentation, source_h_files,
55
# built_h_files, install_datadir, python3, doc_reference,
66
# built_h_file_targets
7-
# Output: install_docdir, install_devhelpdir
7+
# Output: install_docdir, install_devhelpdir, tag_file
88

99
tag_file_modules = [
1010
'mm-common-libstdc++',
@@ -14,9 +14,9 @@ docinstall_flags = []
1414
foreach module : tag_file_modules
1515
depmod = dependency(module, required: false)
1616
if depmod.found()
17-
doxytagfile = depmod.get_pkgconfig_variable('doxytagfile')
18-
htmlrefpub = depmod.get_pkgconfig_variable('htmlrefpub', default: '')
19-
htmlrefdir = depmod.get_pkgconfig_variable('htmlrefdir', default: '')
17+
doxytagfile = depmod.get_variable(pkgconfig: 'doxytagfile', internal: 'doxytagfile')
18+
htmlrefpub = depmod.get_variable(pkgconfig: 'htmlrefpub', internal: 'htmlrefpub', default_value: '')
19+
htmlrefdir = depmod.get_variable(pkgconfig: 'htmlrefdir', internal: 'htmlrefdir', default_value: '')
2020
if htmlrefpub == ''
2121
htmlrefpub = htmlrefdir
2222
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: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ project('libsigc++', 'cpp',
77
'cpp_std=c++11',
88
'warning_level=0',
99
],
10-
meson_version: '>= 0.50.0', # required for python3.path()
10+
meson_version: '>= 0.54.0', # required for meson.override_dependency()
11+
# and dep.get_variable(internal:)
1112
)
1213

1314
sigcxx_api_version = '2.0'
@@ -240,6 +241,19 @@ if not meson.is_subproject()
240241
project_source_root,
241242
'untracked' / 'build_scripts',
242243
)
244+
else
245+
# This is a subproject.
246+
sigcxx_dep = declare_dependency(
247+
dependencies: sigcxx_own_dep,
248+
variables: {
249+
'doxytagfile': tag_file.full_path(),
250+
'htmlrefdir': install_prefix / install_docdir / 'reference' / 'html',
251+
'htmlrefpub': 'http://library.gnome.org/devel/libsigc++/unstable/'
252+
}
253+
)
254+
255+
# A main project that looks for sigcxx_pcname.pc shall find sigcxx_dep.
256+
meson.override_dependency(sigcxx_pcname, sigcxx_dep)
243257
endif
244258

245259
# Print a summary.

sigc++/meson.build

Lines changed: 8 additions & 6 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
# install_includedir, project_source_root, sigc_res
5-
# Output: source_h_files, built_h_files, sigcxx_dep, built_files_root,
5+
# Output: source_h_files, built_h_files, sigcxx_own_dep, built_files_root,
66
# built_h_file_targets
77

88
source_cc_files = [
@@ -166,10 +166,11 @@ if maintainer_mode
166166
source_cc_files, built_cc_file_targets, built_h_file_targets,
167167
extra_sigc_objects,
168168
version: sigcxx_libversion,
169+
darwin_versions: darwin_versions,
169170
cpp_args: extra_sigc_cppflags,
171+
implicit_include_directories: false,
170172
include_directories: extra_include_dirs,
171173
dependencies: sigcxx_build_dep,
172-
darwin_versions: darwin_versions,
173174
install: true,
174175
)
175176

@@ -210,10 +211,11 @@ else # not maintainer_mode
210211
source_cc_files, untracked_built_cc_files,
211212
extra_sigc_objects,
212213
version: sigcxx_libversion,
214+
darwin_versions: darwin_versions,
213215
cpp_args: extra_sigc_cppflags,
216+
implicit_include_directories: false,
214217
include_directories: extra_include_dirs,
215218
dependencies: sigcxx_build_dep,
216-
darwin_versions: darwin_versions,
217219
install: true,
218220
)
219221

@@ -240,9 +242,9 @@ if not meson.is_subproject()
240242
)
241243
endif
242244

243-
# This is useful in the main project when libsigc++ is used as a subproject.
244-
# It's also used when building example programs and test programs.
245-
sigcxx_dep = declare_dependency(
245+
# This is used when building example programs and test programs.
246+
# It's also a part of sigcxx_dep, when libsigc++ is a subproject.
247+
sigcxx_own_dep = declare_dependency(
246248
sources: built_h_file_targets,
247249
link_with: sigcxx_library,
248250
include_directories: extra_include_dirs,

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

@@ -57,7 +57,7 @@ foreach ex : test_programs
5757
endforeach
5858

5959
exe_file = executable(ex_name, ex_sources,
60-
dependencies: sigcxx_dep,
60+
dependencies: sigcxx_own_dep,
6161
gui_app: false,
6262
build_by_default: true
6363
)
@@ -78,7 +78,7 @@ if can_benchmark
7878
endforeach
7979

8080
exe_file = executable(ex_name, ex_sources,
81-
dependencies: [sigcxx_dep, benchmark_dep],
81+
dependencies: [sigcxx_own_dep, benchmark_dep],
8282
gui_app: false,
8383
build_by_default: do_benchmark
8484
)

0 commit comments

Comments
 (0)