From 5253b77d58deb856ec92ad01bf84fb682035d170 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Wed, 19 Oct 2022 16:05:02 +0200 Subject: [PATCH] (#13597) zlib: fix lib name on windows for other compilers than msvc/clang-cl/mingw * fix lib name on windows if not cl like or mingw * modernize a little bit more --- recipes/zlib/all/conanfile.py | 27 ++++++++++--------- .../all/patches/1.2.13/0001-Fix-cmake.patch | 2 +- .../all/patches/1.2.x/0001-fix-cmake.patch | 2 +- recipes/zlib/all/test_package/conanfile.py | 7 ++--- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/recipes/zlib/all/conanfile.py b/recipes/zlib/all/conanfile.py index 74c193ad9cba7..9ae111c632353 100644 --- a/recipes/zlib/all/conanfile.py +++ b/recipes/zlib/all/conanfile.py @@ -1,11 +1,10 @@ from conan import ConanFile from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout -from conan.tools.files import apply_conandata_patches, copy, get, load, replace_in_file, save -from conan.tools.microsoft import is_msvc +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, load, replace_in_file, save from conan.tools.scm import Version import os -required_conan_version = ">=1.49.0" +required_conan_version = ">=1.52.0" class ZlibConan(ConanFile): @@ -28,12 +27,11 @@ class ZlibConan(ConanFile): } @property - def _is_clang_cl(self): - return self.settings.os == "Windows" and self.settings.compiler == "clang" + def _is_mingw(self): + return self.settings.os == "Windows" and self.settings.compiler == "gcc" def export_sources(self): - for p in self.conan_data.get("patches", {}).get(self.version, []): - copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -41,15 +39,18 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC + try: + del self.options.fPIC + except Exception: + pass try: - del self.settings.compiler.libcxx + del self.settings.compiler.libcxx except Exception: - pass + pass try: - del self.settings.compiler.cppstd + del self.settings.compiler.cppstd except Exception: - pass + pass def layout(self): cmake_layout(self, src_folder="src") @@ -103,7 +104,7 @@ def package_info(self): self.cpp_info.set_property("cmake_file_name", "ZLIB") self.cpp_info.set_property("cmake_target_name", "ZLIB::ZLIB") self.cpp_info.set_property("pkg_config_name", "zlib") - if is_msvc(self) or self._is_clang_cl: + if self.settings.os == "Windows" and not self._is_mingw: libname = "zdll" if self.options.shared else "zlib" else: libname = "z" diff --git a/recipes/zlib/all/patches/1.2.13/0001-Fix-cmake.patch b/recipes/zlib/all/patches/1.2.13/0001-Fix-cmake.patch index ede4babb2e94c..a0748ec590d90 100644 --- a/recipes/zlib/all/patches/1.2.13/0001-Fix-cmake.patch +++ b/recipes/zlib/all/patches/1.2.13/0001-Fix-cmake.patch @@ -75,7 +75,7 @@ index b412dc7..a5284ed 100644 endif() -if(UNIX) -+if(MSVC) ++if(WIN32 AND NOT MINGW) + if(BUILD_SHARED_LIBS) + set_target_properties(zlib PROPERTIES ARCHIVE_OUTPUT_NAME zdll) + endif() diff --git a/recipes/zlib/all/patches/1.2.x/0001-fix-cmake.patch b/recipes/zlib/all/patches/1.2.x/0001-fix-cmake.patch index 9a3627d41b04c..f99f0b5219682 100644 --- a/recipes/zlib/all/patches/1.2.x/0001-fix-cmake.patch +++ b/recipes/zlib/all/patches/1.2.x/0001-fix-cmake.patch @@ -64,7 +64,7 @@ endif() -if(UNIX) -+if(MSVC) ++if(WIN32 AND NOT MINGW) + if(BUILD_SHARED_LIBS) + set_target_properties(zlib PROPERTIES ARCHIVE_OUTPUT_NAME zdll) + endif() diff --git a/recipes/zlib/all/test_package/conanfile.py b/recipes/zlib/all/test_package/conanfile.py index d120a992c06a6..0a6bc68712d90 100644 --- a/recipes/zlib/all/test_package/conanfile.py +++ b/recipes/zlib/all/test_package/conanfile.py @@ -7,13 +7,14 @@ class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" - - def requirements(self): - self.requires(self.tested_reference_str) + test_type = "explicit" def layout(self): cmake_layout(self) + def requirements(self): + self.requires(self.tested_reference_str) + def build(self): cmake = CMake(self) cmake.configure()