Skip to content

Meson build: Use libxml2 meson build as fallback #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/meson-windows-2022.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
architecture: x64

- name: Configure
run: meson setup --warnlevel 3 --werror -Dlibxml2_cmake:werror=false -Dmaintainer-mode=false _build
run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=false -Dmaintainer-mode=false _build

- name: Compile
run: ninja -C _build
Expand All @@ -29,7 +29,7 @@ jobs:
run: meson test -C _build

- name: Configure static
run: meson setup --warnlevel 3 --werror -Dlibxml2_cmake:werror=false --default-library static -Dmaintainer-mode=false _build_static
run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=false --default-library static -Dmaintainer-mode=false _build_static

- name: Compile static
run: ninja -C _build_static
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ EXTRA_DIST = \
docs/reference/meson.build \
examples/meson.build \
libxml++/meson.build \
subprojects/libxml2_cmake.wrap \
subprojects/libxml2.wrap \
subprojects/mm-common.wrap \
tests/meson.build \
tools/build_scripts/tutorial-custom-cmd.py \
Expand Down
4 changes: 0 additions & 4 deletions libxml++/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ if host_machine.system() == 'windows'
windows = import('windows')
xmlxx_res = windows.compile_resources(xmlxx_rc)
extra_xmlxx_objects += xmlxx_res

if xml2_is_subproject
xmlxx_all_deps += [winsock_dep, bcrypt_dep]
endif
endif

extra_include_dirs = ['..']
Expand Down
58 changes: 2 additions & 56 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -110,69 +110,15 @@ xml2_req = '>= @0@'.format(xml2_min_ver)
xml2_dep = dependency(
['libxml-2.0', 'LibXml2'],
version: xml2_req,
required: host_machine.system() != 'windows'
fallback: ['libxml2']
)

# Setup CMake subproject for use, if needed
if not xml2_dep.found()
cmake = import('cmake')
opt_var = cmake.subproject_options()
build_shared = get_option('default_library') != 'static'
iconv_dep = dependency('iconv', required: false)
icu_i18n_dep = dependency('icu-i18n', 'ICU',
components: 'in',
required: false)
icu_uc_dep = dependency('icu-uc', 'ICU',
components: 'uc',
required: false)
lzma_dep = dependency(['liblzma','LibLZMA'], required: false)
thread_dep = dependency('threads', required: false)
zlib_dep = dependency('zlib', required: false)
winsock_dep = cpp_compiler.find_library('ws2_32', required: false)
bcrypt_dep = cpp_compiler.find_library('bcrypt', required: false)
cmake_build_type = get_option('buildtype')
if get_option('buildtype') == 'debugoptimized'
cmake_build_type = 'RelWithDebInfo'
elif get_option('buildtype') == 'minsize'
cmake_build_type = 'MinSizeRel'
elif get_option('buildtype') == 'plain'
cmake_build_type = ''
endif
opt_var.add_cmake_defines({
'BUILD_SHARED_LIBS': build_shared,
'CMAKE_BUILD_TYPE': cmake_build_type,
'CMAKE_MSVC_RUNTIME_LIBRARY': '',
'CMAKE_C_FLAGS_INIT': '',
'CMAKE_C_FLAGS_DEBUG': '',
'CMAKE_C_FLAGS_RELEASE': '',
'CMAKE_C_FLAGS_RELWITHDEBINFO': '',
'CMAKE_C_FLAGS_MINSIZEREL': '',
'LIBXML2_WITH_HTTP': host_machine.system() != 'windows' or winsock_dep.found(),
'LIBXML2_WITH_ICONV': iconv_dep.found(),
'LIBXML2_WITH_ICU': icu_i18n_dep.found() and icu_uc_dep.found(),
'LIBXML2_WITH_LZMA': lzma_dep.found(),
'LIBXML2_WITH_PYTHON': false,
'LIBXML2_WITH_TESTS': build_tests,
'LIBXML2_WITH_THREADS': thread_dep.found(),
'LIBXML2_WITH_ZLIB': zlib_dep.found(),
})
xml2_sp = cmake.subproject('libxml2_cmake', options: opt_var)
xml2_dep = xml2_sp.dependency('LibXml2')
endif

xml2_is_subproject = xml2_dep.type_name() == 'internal'

if xml2_is_subproject and build_tests
test('testchar', xml2_sp.target('testchar'))
test('testdict', xml2_sp.target('testdict'))
endif

xmlxx_requires = []
libxml2_lib_pkgconfig = ''

# Put libxml-2.0 in the 'Requires:' section in the generated pkg-config file if
# we found it by pkg-config
if xml2_dep.type_name() == 'pkgconfig'
if xml2_dep.type_name() == 'pkgconfig' or xml2_dep.type_name() == 'internal'
xmlxx_requires += ['libxml-2.0', xml2_req]
else
libxml2_lib_pkgconfig = xml2_dep.get_variable(
Expand Down
3 changes: 3 additions & 0 deletions subprojects/libxml2_cmake.wrap → subprojects/libxml2.wrap
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
url = https://gitlab.gnome.org/GNOME/libxml2.git
revision = master
depth = 1

[provide]
dependency_names = libxml-2.0