Skip to content

Commit b9ffaef

Browse files
committed
Meson build: Use Meson's pkgconfig module
instead of using the *.pc.in templates. Require meson >= 0.62. Remove the can_add_dist_script variable. It's unnecessary when the meson version >= 0.58. Simplify the calls to dependency().get_variable().
1 parent 354f8d2 commit b9ffaef

File tree

5 files changed

+81
-85
lines changed

5 files changed

+81
-85
lines changed

MSVC_NMake/meson.build

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# MSVC_NMake
22

3-
# Input: pkg_conf_data, sigcxxconfig_h_meson, project_build_root, python3,
4-
# can_add_dist_script
3+
# Input: pkg_conf_data, sigcxxconfig_h_meson, project_build_root, python3
54
# Output: sigc_rc
65

76
sigc_rc = configure_file(
@@ -20,13 +19,11 @@ configure_file(
2019
untracked_msvc_nmake = 'untracked' / 'MSVC_NMake'
2120
handle_built_files = project_source_root / 'tools' / 'handle-built-files.py'
2221

23-
if can_add_dist_script
24-
# Distribute built files.
25-
meson.add_dist_script(
26-
python3, handle_built_files, 'dist_gen_msvc_files',
27-
meson.current_build_dir(),
28-
untracked_msvc_nmake,
29-
project_build_root / 'sigc++config.h',
30-
meson.current_build_dir() / 'sigc.rc',
31-
)
32-
endif
22+
# Distribute built files.
23+
meson.add_dist_script(
24+
python3, handle_built_files, 'dist_gen_msvc_files',
25+
meson.current_build_dir(),
26+
untracked_msvc_nmake,
27+
project_build_root / 'sigc++config.h',
28+
meson.current_build_dir() / 'sigc.rc',
29+
)

docs/docs/manual/meson.build

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# docs/docs/manual
22

33
# input: install_datadir, sigcxx_pcname, tutorial_custom_cmd, python3,
4-
# build_documentation, book_name, can_add_dist_script, xsltproc
4+
# build_documentation, book_name, xsltproc
55
# output: can_parse_and_validate, build_pdf_by_default, can_build_pdf,
66
# install_tutorialdir, build_manual_opt, build_manual
77

@@ -95,13 +95,11 @@ if can_build_pdf
9595
)
9696
endif
9797

98-
if can_add_dist_script
99-
# Distribute built files.
100-
meson.add_dist_script(
101-
python3, tutorial_custom_cmd, 'dist_doc',
102-
doc_dist_dir,
103-
meson.current_build_dir(),
104-
meson.current_source_dir() / sigc_manual_xml,
105-
meson.current_build_dir() / sigc_manual_pdf,
106-
)
107-
endif
98+
# Distribute built files.
99+
meson.add_dist_script(
100+
python3, tutorial_custom_cmd, 'dist_doc',
101+
doc_dist_dir,
102+
meson.current_build_dir(),
103+
meson.current_source_dir() / sigc_manual_xml,
104+
meson.current_build_dir() / sigc_manual_pdf,
105+
)

docs/docs/reference/meson.build

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

33
# Input: project_build_root, project_source_root, sigcxx_pcname,
44
# sigcxx_api_version, build_documentation, source_h_files,
5-
# hg_ccg_basenames, install_datadir, python3, doc_reference,
6-
# can_add_dist_script, dot
5+
# hg_ccg_basenames, install_datadir, python3, doc_reference, dot
76
# Output: install_docdir, install_devhelpdir, book_name,
87
# if build_documentation: tag_file
98

@@ -18,7 +17,7 @@ docinstall_flags = []
1817
foreach module : tag_file_modules
1918
depmod = dependency(module, required: false)
2019
if depmod.found()
21-
doxytagfile = depmod.get_variable(pkgconfig: 'doxytagfile', internal: 'doxytagfile', default_value: '')
20+
doxytagfile = depmod.get_variable('doxytagfile', default_value: '')
2221
if doxytagfile != ''
2322
if depmod.type_name() == 'internal'
2423
# Subprojects must build their tag files before doxygen is called.
@@ -28,8 +27,8 @@ foreach module : tag_file_modules
2827
doxygen_tag_targets += subproject(module).get_variable('global_tag_file_target')
2928
endif
3029
endif
31-
htmlrefpub = depmod.get_variable(pkgconfig: 'htmlrefpub', internal: 'htmlrefpub', default_value: '')
32-
htmlrefdir = depmod.get_variable(pkgconfig: 'htmlrefdir', internal: 'htmlrefdir', default_value: '')
30+
htmlrefpub = depmod.get_variable('htmlrefpub', default_value: '')
31+
htmlrefdir = depmod.get_variable('htmlrefdir', default_value: '')
3332
if htmlrefpub == ''
3433
htmlrefpub = htmlrefdir
3534
elif htmlrefdir == ''
@@ -129,14 +128,12 @@ meson.add_install_script(
129128
docinstall_flags
130129
)
131130

132-
if can_add_dist_script
133-
# Distribute built files and files copied by mm-common-get.
134-
meson.add_dist_script(
135-
python3, doc_reference, 'dist_doc',
136-
doctool_dir,
137-
doctool_dist_dir,
138-
meson.current_build_dir(),
139-
tag_file.full_path(),
140-
devhelp_file.full_path(),
141-
)
142-
endif
131+
# Distribute built files and files copied by mm-common-get.
132+
meson.add_dist_script(
133+
python3, doc_reference, 'dist_doc',
134+
doctool_dir,
135+
doctool_dist_dir,
136+
meson.current_build_dir(),
137+
tag_file.full_path(),
138+
devhelp_file.full_path(),
139+
)

meson.build

Lines changed: 19 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ project('libsigc++', 'cpp',
77
'cpp_std=c++17',
88
'warning_level=1',
99
],
10-
meson_version: '>= 0.55.0', # required for meson.add_dist_script(python3, ...)
11-
# and meson.add_install_script(python3, ...)
10+
meson_version: '>= 0.62.0', # required for variables in pkgconfig.generate()
1211
)
1312

1413
sigcxx_api_version = '3.0'
@@ -204,6 +203,7 @@ add_project_arguments(warning_flags, language: 'cpp')
204203
# MSVC: Ignore warnings that aren't really harmful, but make those
205204
# that should not be overlooked stand out.
206205
static_cxxflag = '-DLIBSIGCXX_STATIC'
206+
msvc_static_cxxflag = is_msvc_static ? static_cxxflag : ''
207207
if is_msvc
208208
disable_warnings_list = [
209209
'/EHsc', # avoid warnings caused by exception handling model used
@@ -234,13 +234,6 @@ endif
234234

235235
# Configure files
236236
pkg_conf_data = configuration_data()
237-
pkg_conf_data.set('prefix', install_prefix)
238-
pkg_conf_data.set('exec_prefix', '${prefix}')
239-
pkg_conf_data.set('libdir', '${exec_prefix}' / install_libdir)
240-
pkg_conf_data.set('datarootdir', '${prefix}' / install_datadir)
241-
pkg_conf_data.set('datadir', '${datarootdir}')
242-
pkg_conf_data.set('includedir', '${prefix}' / install_includedir)
243-
pkg_conf_data.set('top_srcdir', project_source_root)
244237
pkg_conf_data.set('PACKAGE_VERSION', meson.project_version())
245238
pkg_conf_data.set('SIGCXX_API_VERSION', sigcxx_api_version)
246239

@@ -250,20 +243,6 @@ endif
250243
pkg_conf_data.set('SIGCXX_MAJOR_VERSION', sigcxx_major_version)
251244
pkg_conf_data.set('SIGCXX_MINOR_VERSION', sigcxx_minor_version)
252245
pkg_conf_data.set('SIGCXX_MICRO_VERSION', sigcxx_micro_version)
253-
pkg_conf_data.set('MSVC_STATIC_CXXFLAG', is_msvc_static ? static_cxxflag : '')
254-
255-
configure_file(
256-
input: 'sigc++.pc.in',
257-
output: sigcxx_pcname + '.pc',
258-
configuration: pkg_conf_data,
259-
install_dir: install_pkgconfigdir,
260-
)
261-
262-
configure_file(
263-
input: 'sigc++-uninstalled.pc.in',
264-
output: sigcxx_pcname + '-uninstalled.pc',
265-
configuration: pkg_conf_data,
266-
)
267246

268247
sigcxxconfig_h_meson = files('sigc++config.h.meson')
269248
install_includeconfigdir = install_libdir / sigcxx_pcname / 'include'
@@ -274,9 +253,6 @@ configure_file(
274253
install_dir: install_includeconfigdir,
275254
)
276255

277-
# add_dist_script() is not allowed in a subproject if meson.version() < 0.58.0.
278-
can_add_dist_script = not meson.is_subproject() or meson.version().version_compare('>= 0.58.0')
279-
280256
#subdir('cmake')
281257
subdir('MSVC_NMake')
282258
subdir('sigc++')
@@ -285,25 +261,23 @@ subdir('tests')
285261
subdir('docs/docs/reference')
286262
subdir('docs/docs/manual')
287263

288-
if can_add_dist_script
289-
# Add a ChangeLog file to the distribution directory.
290-
meson.add_dist_script(
291-
python3, dist_changelog,
292-
project_source_root,
293-
)
294-
# Don't distribute these files and directories.
295-
dont_distribute = [
296-
'.github',
297-
]
298-
# Add build scripts to the distribution directory, and delete .gitignore
299-
# files and an empty $MESON_PROJECT_DIST_ROOT/build/ directory.
300-
meson.add_dist_script(
301-
python3, dist_build_scripts,
302-
project_source_root,
303-
'untracked' / 'build_scripts',
304-
dont_distribute,
305-
)
306-
endif
264+
# Add a ChangeLog file to the distribution directory.
265+
meson.add_dist_script(
266+
python3, dist_changelog,
267+
project_source_root,
268+
)
269+
# Don't distribute these files and directories.
270+
dont_distribute = [
271+
'.github',
272+
]
273+
# Add build scripts to the distribution directory, and delete .gitignore
274+
# files and an empty $MESON_PROJECT_DIST_ROOT/build/ directory.
275+
meson.add_dist_script(
276+
python3, dist_build_scripts,
277+
project_source_root,
278+
'untracked' / 'build_scripts',
279+
dont_distribute,
280+
)
307281

308282
if meson.is_subproject()
309283
pkgconfig_vars = {

sigc++/meson.build

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# sigc++
22

33
# Input: sigcxx_build_dep, sigcxx_pcname, sigcxx_libversion, sigcxx_api_version,
4-
# darwin_versions, install_includedir, sig_rc
4+
# darwin_versions, install_includedir, sig_rc, msvc_static_cxxflag
55
# Output: source_h_files, sigcxx_own_dep
66

77
# There are no built source files in libsigc++-3.0.
@@ -101,6 +101,36 @@ sigcxx_library = library('sigc-' + sigcxx_api_version,
101101
install: true,
102102
)
103103

104+
# Generate .pc files, used by pkg-config.
105+
pkg_config = import('pkgconfig')
106+
pc_common_variables = [
107+
'doxytagfile=${docdir}/reference/lib' + sigcxx_pcname + '.tag',
108+
'htmlrefdir=${docdir}/reference/html',
109+
'htmlrefpub=https://libsigcplusplus.github.io/libsigcplusplus/reference/html',
110+
]
111+
pc_variables = [
112+
'exec_prefix=${prefix}',
113+
'datarootdir=${datadir}',
114+
'docdir=${datadir}/doc/lib' + sigcxx_pcname,
115+
] + pc_common_variables
116+
pc_uninstalled_variables = [
117+
'docdir=${prefix}/docs/docs',
118+
] + pc_common_variables
119+
120+
pkg_config.generate(sigcxx_library,
121+
filebase: sigcxx_pcname,
122+
variables: pc_variables,
123+
uninstalled_variables: pc_uninstalled_variables,
124+
name: meson.project_name(),
125+
description: 'Typesafe signal and callback system for C++',
126+
url: 'https://libsigcplusplus.github.io/libsigcplusplus/',
127+
subdirs: [sigcxx_pcname],
128+
extra_cflags: [
129+
'-I${libdir}/' + sigcxx_pcname + '/include',
130+
msvc_static_cxxflag,
131+
],
132+
)
133+
104134
# This is used when building example programs and test programs.
105135
# It's also a part of sigcxx_dep, when libsigc++ is a subproject.
106136
sigcxx_own_dep = declare_dependency(

0 commit comments

Comments
 (0)