From b03ff45f57d4bceee570cfb7d44a118b85012537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Krupa?= <69798455+tomas-krupa@users.noreply.github.com> Date: Tue, 4 May 2021 15:31:55 +0200 Subject: [PATCH] (#5264) conanized zlib-ng 2.0.0 * conanized zlib-ng 2.0.0 Signed-off-by: tkrupa * removed win static lib suffix Signed-off-by: tkrupa * conanized useful cmake options Signed-off-by: tkrupa * Update recipes/zlib-ng/all/test_package/conanfile.py Test package following common template Co-authored-by: Chris Mc * reduced test package Signed-off-by: tkrupa * test_package depending on zlib.ng explicitely Signed-off-by: tkrupa * using upstream cmake install Signed-off-by: tkrupa * Update recipes/zlib-ng/all/test_package/test_package.c Co-authored-by: Uilian Ries * using cmake wrapper Signed-off-by: tkrupa * Improve zlib-ng Signed-off-by: Uilian Ries * Update recipes/zlib-ng/all/conandata.yml Co-authored-by: Uilian Ries * Update recipes/zlib-ng/config.yml Co-authored-by: Uilian Ries * Update recipes/zlib-ng/all/test_package/test_package.c Co-authored-by: Uilian Ries * Update recipes/zlib-ng/all/conanfile.py Co-authored-by: Chris Mc * Update recipes/zlib-ng/all/test_package/CMakeLists.txt Co-authored-by: Chris Mc * Update recipes/zlib-ng/all/conanfile.py Co-authored-by: Chris Mc Co-authored-by: Chris Mc Co-authored-by: Uilian Ries --- recipes/zlib-ng/all/CMakeLists.txt | 7 ++ recipes/zlib-ng/all/conandata.yml | 4 + recipes/zlib-ng/all/conanfile.py | 98 +++++++++++++++++++ .../zlib-ng/all/test_package/CMakeLists.txt | 9 ++ recipes/zlib-ng/all/test_package/conanfile.py | 17 ++++ .../zlib-ng/all/test_package/test_package.c | 15 +++ recipes/zlib-ng/config.yml | 3 + 7 files changed, 153 insertions(+) create mode 100644 recipes/zlib-ng/all/CMakeLists.txt create mode 100644 recipes/zlib-ng/all/conandata.yml create mode 100644 recipes/zlib-ng/all/conanfile.py create mode 100644 recipes/zlib-ng/all/test_package/CMakeLists.txt create mode 100644 recipes/zlib-ng/all/test_package/conanfile.py create mode 100644 recipes/zlib-ng/all/test_package/test_package.c create mode 100644 recipes/zlib-ng/config.yml diff --git a/recipes/zlib-ng/all/CMakeLists.txt b/recipes/zlib-ng/all/CMakeLists.txt new file mode 100644 index 00000000000000..217b9530b904d4 --- /dev/null +++ b/recipes/zlib-ng/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.11) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("source_subfolder") diff --git a/recipes/zlib-ng/all/conandata.yml b/recipes/zlib-ng/all/conandata.yml new file mode 100644 index 00000000000000..82c5be8c12e3a7 --- /dev/null +++ b/recipes/zlib-ng/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.0.2": + sha256: "dd37886f22ca6890e403ea6c1d60f36eab1d08d2f232a35f5b02126621149d28" + url: "https://github.com/Dead2/zlib-ng/archive/2.0.2.tar.gz" diff --git a/recipes/zlib-ng/all/conanfile.py b/recipes/zlib-ng/all/conanfile.py new file mode 100644 index 00000000000000..c6d0fe5789cdc8 --- /dev/null +++ b/recipes/zlib-ng/all/conanfile.py @@ -0,0 +1,98 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + +import os + +class ZlibNgConan(ConanFile): + name = "zlib-ng" + description = "zlib data compression library for the next generation systems" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/Dead2/zlib-ng/" + license ="Zlib" + topics = ("conan", "zlib", "compression") + exports_sources = ["CMakeLists.txt"] + generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + options = {"shared": [True, False], + "zlib_compat": [True, False], + "with_gzfileop": [True, False], + "with_optim": [True, False], + "with_new_strategies": [True, False], + "with_native_instructions": [True, False], + "fPIC": [True, False]} + default_options = {"shared": False, + "zlib_compat": False, + "with_gzfileop": True, + "with_optim": False, + "with_new_strategies": True, + "with_native_instructions": False, + "fPIC": True} + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + os.rename("zlib-ng-{}".format(self.version), self._source_subfolder) + + def validate(self): + if self.options.zlib_compat and not self.options.with_gzfileop: + raise ConanInvalidConfiguration("The option 'with_gzfileop' must be True when 'zlib_compat' is True.") + + def _configure_cmake(self): + if not self._cmake: + self._cmake = CMake(self) + self._cmake.definitions["ZLIB_ENABLE_TESTS"] = False + self._cmake.definitions["ZLIB_COMPAT"] = self.options.zlib_compat + self._cmake.definitions["WITH_GZFILEOP"] = self.options.with_gzfileop + self._cmake.definitions["WITH_OPTIM"] = self.options.with_optim + self._cmake.definitions["WITH_NEW_STRATEGIES"] = self.options.with_new_strategies + self._cmake.definitions["WITH_NATIVE_INSTRUCTIONS"] = self.options.with_native_instructions + + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + #FIXME: CMake targets are https://github.com/zlib-ng/zlib-ng/blob/29fd4672a2279a0368be936d7cd44d013d009fae/CMakeLists.txt#L914 + suffix = "" if self.options.zlib_compat else "-ng" + self.cpp_info.names["pkg_config"] = "zlib" + suffix + if self.settings.os == "Windows": + if self.settings.build_type == "Debug": + self.cpp_info.libs = ["zlib{}d".format(suffix)] + else: + self.cpp_info.libs = ["zlib{}".format(suffix)] + + else: + self.cpp_info.libs = ["z{}".format(suffix)] + if self.options.zlib_compat: + self.cpp_info.defines.append("ZLIB_COMPAT") + if self.options.with_gzfileop: + self.cpp_info.defines.append("WITH_GZFILEOP") + if not self.options.with_new_strategies: + self.cpp_info.defines.extend(["NO_QUICK_STRATEGY", "NO_MEDIUM_STRATEGY"]) diff --git a/recipes/zlib-ng/all/test_package/CMakeLists.txt b/recipes/zlib-ng/all/test_package/CMakeLists.txt new file mode 100644 index 00000000000000..6c67afe1e534ee --- /dev/null +++ b/recipes/zlib-ng/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} CONAN_PKG::zlib-ng) +set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99) diff --git a/recipes/zlib-ng/all/test_package/conanfile.py b/recipes/zlib-ng/all/test_package/conanfile.py new file mode 100644 index 00000000000000..abcaeed3f89b67 --- /dev/null +++ b/recipes/zlib-ng/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/zlib-ng/all/test_package/test_package.c b/recipes/zlib-ng/all/test_package/test_package.c new file mode 100644 index 00000000000000..b8a7330c8edef4 --- /dev/null +++ b/recipes/zlib-ng/all/test_package/test_package.c @@ -0,0 +1,15 @@ +#include +#include + +#ifdef ZLIB_COMPAT +# include "zlib.h" +# define ZLIB_VERSION zlibVersion +#else +# include "zlib-ng.h" +# define ZLIB_VERSION zlibng_version +#endif + +int main(void) { + printf("ZLIB NG VERSION: %s\n", ZLIB_VERSION()); + return EXIT_SUCCESS; +} diff --git a/recipes/zlib-ng/config.yml b/recipes/zlib-ng/config.yml new file mode 100644 index 00000000000000..5df97e2cc232e3 --- /dev/null +++ b/recipes/zlib-ng/config.yml @@ -0,0 +1,3 @@ +versions: + "2.0.2": + folder: all