From 891f632b2eeb9add221e2c23705d6bde1ad8248b Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Mon, 20 Feb 2023 13:53:46 +0100 Subject: [PATCH 1/5] bump xz_utils --- recipes/libxml2/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/libxml2/all/conanfile.py b/recipes/libxml2/all/conanfile.py index 22f3f4151fbd6..b9e12c84c810f 100644 --- a/recipes/libxml2/all/conanfile.py +++ b/recipes/libxml2/all/conanfile.py @@ -95,7 +95,7 @@ def requirements(self): if self.options.zlib: self.requires("zlib/1.2.13") if self.options.lzma: - self.requires("xz_utils/5.2.5") + self.requires("xz_utils/5.4.0") if self.options.iconv: self.requires("libiconv/1.17", transitive_headers=True, transitive_libs=True) if self.options.icu: From f9ef5de5f47fb02402fa71b4d9a125feb706f57a Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Mon, 20 Feb 2023 14:01:23 +0100 Subject: [PATCH 2/5] modernize more - use NMakeToolchain & NMakeDeps for msvc build - check `tools.gnu:pkg_config` - use fix_apple_shared_install_name() instead of patching upstream configure file --- recipes/libxml2/all/conanfile.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/recipes/libxml2/all/conanfile.py b/recipes/libxml2/all/conanfile.py index b9e12c84c810f..f458a1f3ec970 100644 --- a/recipes/libxml2/all/conanfile.py +++ b/recipes/libxml2/all/conanfile.py @@ -1,17 +1,18 @@ from conan import ConanFile -from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv -from conan.tools.scm import Version +from conan.tools.apple import fix_apple_shared_install_name from conan.tools.build import cross_building, build_jobs +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv from conan.tools.files import copy, get, rename, rm, rmdir, replace_in_file, save, chdir, mkdir from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps from conan.tools.layout import basic_layout -from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path, VCVars +from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path, NMakeDeps, NMakeToolchain +from conan.tools.scm import Version import os import itertools import textwrap -required_conan_version = ">=1.53.0" +required_conan_version = ">=1.55.0" class Libxml2Conan(ConanFile): @@ -104,26 +105,22 @@ def requirements(self): def build_requirements(self): if not (is_msvc(self) or self._is_mingw_windows): if self.options.zlib or self.options.lzma or self.options.icu: - self.tool_requires("pkgconf/1.9.3") + if not self.conf.get("tools.gnu:pkg_config", check_type=str): + self.tool_requires("pkgconf/1.9.3") if self._settings_build.os == "Windows": self.win_bash = True if not self.conf.get("tools.microsoft.bash:path", check_type=str): self.tool_requires("msys2/cci.latest") def source(self): - get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], strip_root=True) def generate(self): if is_msvc(self): - tc = VCVars(self) + tc = NMakeToolchain(self) tc.generate() - env = Environment() - # TODO: no conan v2 build helper for NMake yet (see https://github.com/conan-io/conan/issues/12188) - # So populate CL with AutotoolsToolchain cflags - c_flags = AutotoolsToolchain(self).cflags - if c_flags: - env.define("CL", c_flags) - env.vars(self).save_script("conanbuildenv_nmake") + deps = NMakeDeps(self) + deps.generate() elif self._is_mingw_windows: pass # nothing to do for mingw? it calls mingw-make directly else: @@ -277,10 +274,6 @@ def _patch_sources(self): replace_in_file(self, os.path.join(self.source_folder, "win32", makefile), "install-libs : all", "install-libs :") - # relocatable shared lib on macOS - replace_in_file(self, os.path.join(self.source_folder, "configure"), - "-install_name \\$rpath/", - "-install_name @rpath/") def build(self): self._patch_sources() @@ -333,6 +326,7 @@ def package(self): rmdir(self, os.path.join(self.package_folder, "share")) rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + fix_apple_shared_install_name(self) for header in ["win32config.h", "wsockcompat.h"]: copy(self, pattern=header, src=os.path.join(self.source_folder, "include"), From 2a658805aea2febb5da640ef804357619a536c3d Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Wed, 8 Mar 2023 13:14:44 +0100 Subject: [PATCH 3/5] fix test of custom CMake variables --- recipes/libxml2/all/test_cmake_module_package/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/libxml2/all/test_cmake_module_package/CMakeLists.txt b/recipes/libxml2/all/test_cmake_module_package/CMakeLists.txt index 90d37ee9afb23..de255480513cc 100644 --- a/recipes/libxml2/all/test_cmake_module_package/CMakeLists.txt +++ b/recipes/libxml2/all/test_cmake_module_package/CMakeLists.txt @@ -18,7 +18,7 @@ set(_custom_vars LIBXML2_VERSION_STRING ) foreach(_custom_var ${_custom_vars}) - if(DEFINED _custom_var) + if(DEFINED ${_custom_var}) message(STATUS "${_custom_var}: ${${_custom_var}}") else() message(FATAL_ERROR "${_custom_var} not defined") From c7eb39cfd98122a3984c71adb464ff83147d249c Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Wed, 8 Mar 2023 15:29:36 +0100 Subject: [PATCH 4/5] more robust definition of custom CMake variables --- recipes/libxml2/all/conanfile.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/recipes/libxml2/all/conanfile.py b/recipes/libxml2/all/conanfile.py index f458a1f3ec970..f46e383188ef7 100644 --- a/recipes/libxml2/all/conanfile.py +++ b/recipes/libxml2/all/conanfile.py @@ -338,33 +338,31 @@ def package(self): def _create_cmake_module_variables(self, module_file): # FIXME: also define LIBXML2_XMLLINT_EXECUTABLE variable - content = textwrap.dedent("""\ + content = textwrap.dedent(f"""\ set(LibXml2_FOUND TRUE) set(LIBXML2_FOUND TRUE) if(DEFINED LibXml2_INCLUDE_DIRS) - set(LIBXML2_INCLUDE_DIR ${LibXml2_INCLUDE_DIRS}) - set(LIBXML2_INCLUDE_DIRS ${LibXml2_INCLUDE_DIRS}) + set(LIBXML2_INCLUDE_DIR ${{LibXml2_INCLUDE_DIRS}}) + set(LIBXML2_INCLUDE_DIRS ${{LibXml2_INCLUDE_DIRS}}) elseif(DEFINED libxml2_INCLUDE_DIRS) - set(LIBXML2_LIBRARIES ${libxml2_INCLUDE_DIRS}) - set(LIBXML2_LIBRARY ${libxml2_INCLUDE_DIRS}) + set(LIBXML2_LIBRARIES ${{libxml2_INCLUDE_DIRS}}) + set(LIBXML2_LIBRARY ${{libxml2_INCLUDE_DIRS}}) endif() if(DEFINED LibXml2_LIBRARIES) - set(LIBXML2_LIBRARIES ${LibXml2_LIBRARIES}) - set(LIBXML2_LIBRARY ${LibXml2_LIBRARIES}) + set(LIBXML2_LIBRARIES ${{LibXml2_LIBRARIES}}) + set(LIBXML2_LIBRARY ${{LibXml2_LIBRARIES}}) elseif(DEFINED libxml2_LIBRARIES) - set(LIBXML2_LIBRARIES ${libxml2_LIBRARIES}) - set(LIBXML2_LIBRARY ${libxml2_LIBRARIES}) + set(LIBXML2_LIBRARIES ${{libxml2_LIBRARIES}}) + set(LIBXML2_LIBRARY ${{libxml2_LIBRARIES}}) endif() if(DEFINED LibXml2_DEFINITIONS) - set(LIBXML2_DEFINITIONS ${LibXml2_DEFINITIONS}) + set(LIBXML2_DEFINITIONS ${{LibXml2_DEFINITIONS}}) elseif(DEFINED libxml2_DEFINITIONS) - set(LIBXML2_DEFINITIONS ${libxml2_DEFINITIONS}) - endif() - if(DEFINED LibXml2_VERSION) - set(LIBXML2_VERSION_STRING ${LibXml2_VERSION}) - elseif(DEFINED libxml2_VERSION) - set(LIBXML2_VERSION_STRING ${libxml2_VERSION}) + set(LIBXML2_DEFINITIONS ${{libxml2_DEFINITIONS}}) + else() + set(LIBXML2_DEFINITIONS "") endif() + set(LIBXML2_VERSION_STRING {self.version}) """) save(self, module_file, content) From bec566e49b86807b73bb6d480fceb57903b3e555 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Wed, 8 Mar 2023 15:32:34 +0100 Subject: [PATCH 5/5] improve LIBXML2_VERSION_STRING --- recipes/libxml2/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/libxml2/all/conanfile.py b/recipes/libxml2/all/conanfile.py index f46e383188ef7..04bda9f32e243 100644 --- a/recipes/libxml2/all/conanfile.py +++ b/recipes/libxml2/all/conanfile.py @@ -362,7 +362,7 @@ def _create_cmake_module_variables(self, module_file): else() set(LIBXML2_DEFINITIONS "") endif() - set(LIBXML2_VERSION_STRING {self.version}) + set(LIBXML2_VERSION_STRING "{self.version}") """) save(self, module_file, content)