From 470b25bb087553ebe02fd4be0c1e5eeb52da21f7 Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Thu, 6 Jun 2024 08:32:01 -0700 Subject: [PATCH 1/2] Meson build: Use libxml2 meson build as fallback Fixes #67 --- .github/workflows/meson-windows-2022.yml | 4 +- Makefile.am | 2 +- libxml++/meson.build | 4 -- meson.build | 61 +------------------ .../{libxml2_cmake.wrap => libxml2.wrap} | 3 + 5 files changed, 7 insertions(+), 67 deletions(-) rename subprojects/{libxml2_cmake.wrap => libxml2.wrap} (68%) diff --git a/.github/workflows/meson-windows-2022.yml b/.github/workflows/meson-windows-2022.yml index 27a924b7..0f27f89b 100644 --- a/.github/workflows/meson-windows-2022.yml +++ b/.github/workflows/meson-windows-2022.yml @@ -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 @@ -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 diff --git a/Makefile.am b/Makefile.am index 92c59007..b7d45e28 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/libxml++/meson.build b/libxml++/meson.build index 93736f9f..34233f9a 100644 --- a/libxml++/meson.build +++ b/libxml++/meson.build @@ -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 = ['..'] diff --git a/meson.build b/meson.build index e4b27ed9..a111cee5 100644 --- a/meson.build +++ b/meson.build @@ -110,63 +110,9 @@ 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 = '' @@ -174,11 +120,6 @@ libxml2_lib_pkgconfig = '' # we found it by pkg-config if xml2_dep.type_name() == 'pkgconfig' xmlxx_requires += ['libxml-2.0', xml2_req] -else - libxml2_lib_pkgconfig = xml2_dep.get_variable( - cmake: 'LIBXML2_LIBRARIES', - default_value: 'LibXml2.lib', - ) endif xmlxx_requires = ' '.join(xmlxx_requires) diff --git a/subprojects/libxml2_cmake.wrap b/subprojects/libxml2.wrap similarity index 68% rename from subprojects/libxml2_cmake.wrap rename to subprojects/libxml2.wrap index a6f60f33..9c0e5f6d 100644 --- a/subprojects/libxml2_cmake.wrap +++ b/subprojects/libxml2.wrap @@ -2,3 +2,6 @@ url = https://gitlab.gnome.org/GNOME/libxml2.git revision = master depth = 1 + +[provide] +dependency_names = libxml-2.0 From 5ca3a106e0ddf3b74fcd0e5d68d928d14e379cad Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Sat, 8 Jun 2024 08:58:17 -0700 Subject: [PATCH 2/2] meson: set LIBXML2_LIB_NO_PKGCONFIG for cmake dep --- meson.build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index a111cee5..4bebf5f9 100644 --- a/meson.build +++ b/meson.build @@ -118,8 +118,13 @@ 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( + cmake: 'LIBXML2_LIBRARIES', + default_value: 'LibXml2.lib', + ) endif xmlxx_requires = ' '.join(xmlxx_requires)