Skip to content

Commit d4389e1

Browse files
committed
Meson build: Use Meson's pkgconfig module
instead of using the libxml++.pc.in template. Require meson >= 0.62. Remove the can_add_dist_script variable. It's unnecessary when the meson version >= 0.58.
1 parent bc072b6 commit d4389e1

File tree

4 files changed

+73
-73
lines changed

4 files changed

+73
-73
lines changed

docs/manual/meson.build

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

33
# input: install_datadir, xmlxx_pcname, tutorial_custom_cmd_py, 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

@@ -106,13 +106,11 @@ if can_build_pdf
106106
)
107107
endif
108108

109-
if can_add_dist_script
110-
# Distribute built files.
111-
meson.add_dist_script(
112-
python3, tutorial_custom_cmd_py, 'dist_doc',
113-
doc_dist_dir,
114-
meson.current_build_dir(),
115-
meson.current_build_dir() / 'libxml++.xml',
116-
meson.current_build_dir() / 'libxml++.pdf',
117-
)
118-
endif
109+
# Distribute built files.
110+
meson.add_dist_script(
111+
python3, tutorial_custom_cmd_py, 'dist_doc',
112+
doc_dist_dir,
113+
meson.current_build_dir(),
114+
meson.current_build_dir() / 'libxml++.xml',
115+
meson.current_build_dir() / 'libxml++.pdf',
116+
)

docs/reference/meson.build

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

33
# Input: project_build_root, project_source_root, xmlxx_pcname,
44
# xmlxx_api_version, build_documentation, source_h_files,
5-
# install_datadir, python3, doc_reference_py, can_add_dist_script, dot
5+
# install_datadir, python3, doc_reference_py, dot
66
# Output: install_docdir, install_devhelpdir, book_name,
77
# if build_documentation: tag_file
88

@@ -128,14 +128,12 @@ meson.add_install_script(
128128
docinstall_flags
129129
)
130130

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

libxml++/meson.build

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

33
# Input: xmlxx_build_dep, xmlxx_pcname, xmlxx_libversion, xmlxx_api_version,
4-
# install_includedir, xmlxx_rc, xmlxx_libname, macos_darwin_versions
4+
# install_includedir, xmlxx_rc, xmlxx_libname, macos_darwin_versions,
5+
# xmlxx_pc_requires, libxml2_lib_pkgconfig
56
# Output: source_h_files, xmlxx_own_dep
67

78
# There are no built source files in libxml++-5.0.
@@ -116,6 +117,35 @@ xmlxx_library = library(xmlxx_libname,
116117
install: true,
117118
)
118119

120+
# Generate .pc files, used by pkg-config.
121+
pkg_config = import('pkgconfig')
122+
pc_common_variables = [
123+
'doxytagfile=${docdir}/reference/' + xmlxx_pcname + '.tag',
124+
'htmlrefdir=${docdir}/reference/html',
125+
'htmlrefpub=https://libxmlplusplus.github.io/libxmlplusplus/reference/html',
126+
]
127+
pc_variables = [
128+
'exec_prefix=${prefix}',
129+
'datarootdir=${datadir}',
130+
'docdir=${datadir}/doc/' + xmlxx_pcname,
131+
] + pc_common_variables
132+
pc_uninstalled_variables = [
133+
'docdir=${prefix}/docs',
134+
] + pc_common_variables
135+
136+
pkg_config.generate(xmlxx_library,
137+
filebase: xmlxx_pcname,
138+
variables: pc_variables,
139+
uninstalled_variables: pc_uninstalled_variables,
140+
name: meson.project_name(),
141+
description: 'C++ wrapper for libxml2',
142+
url: 'https://libxmlplusplus.github.io/libxmlplusplus/',
143+
requires: xmlxx_pc_requires,
144+
libraries: libxml2_lib_pkgconfig,
145+
subdirs: [xmlxx_pcname],
146+
extra_cflags: ['-I${libdir}/' + xmlxx_pcname + '/include'],
147+
)
148+
119149
# This is used when building example programs and test programs.
120150
# It's also a part of xmlxx_dep, when libxml++ is a subproject.
121151
xmlxx_own_dep = declare_dependency(

meson.build

Lines changed: 23 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ project('libxml++', 'cpp',
77
'warning_level=1',
88
'cpp_std=c++17',
99
],
10-
meson_version: '>= 0.60.0', # required for dependency('iconv')
10+
meson_version: '>= 0.62.0', # required for variables in pkgconfig.generate()
1111
)
1212

1313
xmlxx_api_version = '5.0'
@@ -113,22 +113,20 @@ xml2_dep = dependency(
113113
fallback: ['libxml2']
114114
)
115115

116-
xmlxx_requires = []
117-
libxml2_lib_pkgconfig = ''
116+
xmlxx_pc_requires = []
117+
libxml2_lib_pkgconfig = []
118118

119119
# Put libxml-2.0 in the 'Requires:' section in the generated pkg-config file if
120120
# we found it by pkg-config
121121
if xml2_dep.type_name() == 'pkgconfig' or xml2_dep.type_name() == 'internal'
122-
xmlxx_requires += ['libxml-2.0', xml2_req]
122+
xmlxx_pc_requires += ['libxml-2.0' + xml2_req]
123123
else
124-
libxml2_lib_pkgconfig = xml2_dep.get_variable(
124+
libxml2_lib_pkgconfig += [xml2_dep.get_variable(
125125
cmake: 'LIBXML2_LIBRARIES',
126126
default_value: 'LibXml2.lib',
127-
)
127+
)]
128128
endif
129129

130-
xmlxx_requires = ' '.join(xmlxx_requires)
131-
132130
# Make sure we link to libxml-2.0
133131
xmlxx_build_dep = [xml2_dep]
134132

@@ -270,20 +268,8 @@ endif
270268

271269
# Configure files
272270
pkg_conf_data = configuration_data()
273-
pkg_conf_data.set('prefix', install_prefix)
274-
pkg_conf_data.set('exec_prefix', '${prefix}')
275-
pkg_conf_data.set('libdir', '${exec_prefix}' / install_libdir)
276-
pkg_conf_data.set('datarootdir', '${prefix}' / install_datadir)
277-
pkg_conf_data.set('datadir', '${datarootdir}')
278-
pkg_conf_data.set('includedir', '${prefix}' / install_includedir)
279271
pkg_conf_data.set('PACKAGE_NAME', meson.project_name()) # MSVC_NMake/libxml++/libxml++.rc
280-
pkg_conf_data.set('PACKAGE_TARNAME', meson.project_name())
281272
pkg_conf_data.set('PACKAGE_VERSION', meson.project_version())
282-
pkg_conf_data.set('LIBXMLXX_MODULE_NAME', xmlxx_pcname)
283-
pkg_conf_data.set('LIBXMLXX_API_VERSION', xmlxx_api_version)
284-
pkg_conf_data.set('LIBXMLXX_MODULES', xmlxx_requires)
285-
pkg_conf_data.set('LIBXML2_LIB_NO_PKGCONFIG', libxml2_lib_pkgconfig)
286-
pkg_conf_data.set('MSVC_TOOLSET_VER', msvc14x_toolset_ver)
287273

288274
if not build_deprecated_api
289275
pkg_conf_data.set('LIBXMLXX_DISABLE_DEPRECATED', 1)
@@ -308,13 +294,6 @@ if cpp_compiler.get_argument_syntax() == 'msvc'
308294
endif
309295
endif
310296

311-
configure_file(
312-
input: 'libxml++.pc.in',
313-
output: xmlxx_pcname + '.pc',
314-
configuration: pkg_conf_data,
315-
install_dir: install_pkgconfigdir,
316-
)
317-
318297
xmlxxconfig_h_meson = files('libxml++config.h.meson')
319298
install_includeconfigdir = install_libdir / xmlxx_pcname / 'include'
320299
configure_file(
@@ -324,36 +303,31 @@ configure_file(
324303
install_dir: install_includeconfigdir,
325304
)
326305

327-
# add_dist_script() is not allowed in a subproject if meson.version() < 0.58.0.
328-
can_add_dist_script = not meson.is_subproject() or meson.version().version_compare('>= 0.58.0')
329-
330306
subdir('MSVC_NMake/libxml++')
331307
subdir('libxml++')
332308
subdir('examples')
333309
subdir('tests')
334310
subdir('docs/reference')
335311
subdir('docs/manual')
336312

337-
if can_add_dist_script
338-
# Add a ChangeLog file to the distribution directory.
339-
meson.add_dist_script(
340-
python3, dist_changelog_py,
341-
project_source_root,
342-
)
313+
# Add a ChangeLog file to the distribution directory.
314+
meson.add_dist_script(
315+
python3, dist_changelog_py,
316+
project_source_root,
317+
)
343318

344-
# Don't distribute these files and directories.
345-
dont_distribute = [
346-
'.github',
347-
]
348-
# Add build scripts to the distribution directory, and delete .gitignore
349-
# files and an empty $MESON_PROJECT_DIST_ROOT/build/ directory.
350-
meson.add_dist_script(
351-
python3, dist_build_scripts_py,
352-
project_source_root,
353-
'untracked' / 'build_scripts',
354-
dont_distribute,
355-
)
356-
endif
319+
# Don't distribute these files and directories.
320+
dont_distribute = [
321+
'.github',
322+
]
323+
# Add build scripts to the distribution directory, and delete .gitignore
324+
# files and an empty $MESON_PROJECT_DIST_ROOT/build/ directory.
325+
meson.add_dist_script(
326+
python3, dist_build_scripts_py,
327+
project_source_root,
328+
'untracked' / 'build_scripts',
329+
dont_distribute,
330+
)
357331

358332
if meson.is_subproject()
359333
pkgconfig_vars = {

0 commit comments

Comments
 (0)