Repository: conan-io/conan-center-index

Issue:
minizip-ng: Add 3.0.0
Specify library name and version:  **minizip-ng/3.0.0**

- [x] I've read the [guidelines](https://github.com/conan-io/conan-center-index/blob/master/docs/how_to_add_packages.md) for contributing.
- [x] I've followed the [PEP8](https://www.python.org/dev/peps/pep-0008/) style guides for Python code in the recipes.
- [x] I've used the [latest](https://github.com/conan-io/conan/releases/latest) Conan client version.
- [x] I've tried at least one configuration locally with the
      [conan-center hook](https://github.com/conan-io/hooks.git) activated.

Closes #4386.


Discussion:

Resolving patch:
diff --git a/recipes/minizip-ng/all/conanfile.py b/recipes/minizip-ng/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/minizip-ng/all/conanfile.py
@@ -0,0 +1,156 @@
+import os
+from conans import ConanFile, tools, CMake
+
+
+class MinizipNgConan(ConanFile):
+    name = "minizip-ng"
+    description = "Fork of the popular zip manipulation library found in the zlib distribution."
+    topics = ("conan", "compression", "zip")
+    url = "https://github.com/conan-io/conan-center-index"
+    homepage = "https://github.com/zlib-ng/minizip-ng"
+    license = "Zlib"
+    exports_sources = "CMakeLists.txt"
+    generators = "cmake", "cmake_find_package", "pkg_config"
+    settings = "os", "compiler", "build_type", "arch"
+    options = {
+        "shared": [True, False],
+        "fPIC": [True, False],
+        "mz_compatibility": [True, False],
+        "with_zlib": [True, False],
+        "with_bzip2": [True, False],
+        "with_lzma": [True, False],
+        "with_zstd": [True, False],
+        "with_openssl": [True, False],
+        "with_iconv": [True, False],
+        "with_libbsd": [True, False],
+        "with_libcomp": [True, False],
+    }
+    default_options = {
+        "shared": False,
+        "fPIC": True,
+        "mz_compatibility": False,
+        "with_zlib": True,
+        "with_bzip2": True,
+        "with_lzma": True,
+        "with_zstd": True,
+        "with_openssl": True,
+        "with_iconv": True,
+        "with_libbsd": True,
+        "with_libcomp": 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
+            del self.options.with_iconv
+            del self.options.with_libbsd
+        if not tools.is_apple_os(self.settings.os):
+            del self.options.with_libcomp
+
+    def build_requirements(self):
+        self.build_requires('pkgconf/1.7.3')
+
+    def configure(self):
+        if self.options.shared:
+            del self.options.fPIC
+        del self.settings.compiler.cppstd
+        del self.settings.compiler.libcxx
+        if self.options.mz_compatibility:
+            self.provides = "minizip"
+        if self.options.get_safe("with_libcomp"):
+            del self.options.with_zlib
+
+    def requirements(self):
+        if self.options.get_safe("with_zlib"):
+            self.requires("zlib/1.2.11")
+        if self.options.with_bzip2:
+            self.requires("bzip2/1.0.8")
+        if self.options.with_lzma:
+            self.requires("xz_utils/5.2.5")
+        if self.options.with_zstd:
+            self.requires("zstd/1.4.8")
+        if self.options.with_openssl:
+            self.requires("openssl/1.1.1k")
+        if self.settings.os != "Windows":
+            if self.options.get_safe("with_iconv"):
+                self.requires("libiconv/1.16")
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)
+
+    def _configure_cmake(self):
+        if self._cmake:
+            return self._cmake
+        self._cmake = CMake(self)
+        self._cmake.definitions["MZ_FETCH_LIBS"] = False
+        self._cmake.definitions["MZ_COMPAT"] = self.options.mz_compatibility
+        self._cmake.definitions["MZ_ZLIB"] = self.options.get_safe("with_zlib", False)
+        self._cmake.definitions["MZ_BZIP2"] = self.options.with_bzip2
+        self._cmake.definitions["MZ_LZMA"] = self.options.with_lzma
+        self._cmake.definitions["MZ_ZSTD"] = self.options.with_zstd
+        self._cmake.definitions["MZ_OPENSSL"] = self.options.with_openssl
+        self._cmake.definitions["MZ_LIBCOMP"] = self.options.get_safe("with_libcomp", False)
+
+        if self.settings.os != "Windows":
+            self._cmake.definitions["MZ_ICONV"] = self.options.with_iconv
+            self._cmake.definitions["MZ_LIBBSD"] = self.options.with_libbsd
+
+        self._cmake.configure(build_folder=self._build_subfolder)
+        return self._cmake
+
+    def _patch_sources(self):
+        tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"),
+                              "set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE 1)",
+                              "")
+
+    def build(self):
+        self._patch_sources()
+        cmake = self._configure_cmake()
+        cmake.build()
+
+    def package(self):
+        self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
+        cmake = self._configure_cmake()
+        cmake.install()
+        tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
+        tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
+
+    def package_info(self):
+        self.cpp_info.filenames["cmake_find_package"] = "minizip"
+        self.cpp_info.filenames["cmake_find_package_multi"] = "minizip"
+        self.cpp_info.names["cmake_find_package"] = "MINIZIP"
+        self.cpp_info.names["cmake_find_package_multi"] = "MINIZIP"
+        self.cpp_info.names["pkg_config"] = "minizip"
+        self.cpp_info.components["minizip"].names["cmake_find_package"] = "minizip"
+        self.cpp_info.components["minizip"].names["cmake_find_package_multi"] = "minizip"
+        self.cpp_info.components["minizip"].libs = tools.collect_libs(self)
+
+        if self.options.get_safe("with_zlib"):
+            self.cpp_info.components["minizip"].requires.append("zlib::zlib")
+        if self.options.with_bzip2:
+            self.cpp_info.components["minizip"].requires.append("bzip2::bzip2")
+        if self.options.with_lzma:
+            self.cpp_info.components["minizip"].requires.append("xz_utils::xz_utils")
+        if self.options.with_zstd:
+            self.cpp_info.components["minizip"].requires.append("zstd::zstd")
+        if self.options.with_openssl:
+            self.cpp_info.components["minizip"].requires.append("openssl::openssl")
+        if self.settings.os != "Windows" and self.options.with_iconv:
+            self.cpp_info.components["minizip"].requires.append("libiconv::libiconv")
+
+        if self.options.with_lzma:
+            self.cpp_info.components["minizip"].defines.append('HAVE_LZMA')
+        if tools.is_apple_os(self.settings.os) and self.options.get_safe("with_libcomp"):
+            self.cpp_info.components["minizip"].defines.append('HAVE_LIBCOMP')
+        if self.options.with_bzip2:
+            self.cpp_info.components["minizip"].defines.append('HAVE_BZIP2')


Test patch:
diff --git a/recipes/minizip-ng/all/test_package/CMakeLists.txt b/recipes/minizip-ng/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/minizip-ng/all/test_package/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.1)
+project(test_package)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup(TARGETS)
+
+find_package(minizip CONFIG REQUIRED)
+
+add_executable(${PROJECT_NAME} test_package.c)
+target_link_libraries(${PROJECT_NAME} MINIZIP::minizip)
+set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99)
diff --git a/recipes/minizip-ng/all/test_package/conanfile.py b/recipes/minizip-ng/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/minizip-ng/all/test_package/conanfile.py
@@ -0,0 +1,17 @@
+from conans import ConanFile, CMake, tools
+import os
+
+
+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/minizip-ng/all/test_package/test_package.c b/recipes/minizip-ng/all/test_package/test_package.c
new file mode 100644
--- /dev/null
+++ b/recipes/minizip-ng/all/test_package/test_package.c
@@ -0,0 +1,12 @@
+#include <stdlib.h>
+#include <mz.h>
+#include <mz_os.h>
+
+int main(int argc, char** argv)
+{
+    char output[256];
+    memset(output, 'z', sizeof(output));
+    int32_t err = mz_path_resolve("c:\\test\\.", output, sizeof(output));
+    int32_t ok = (strcmp(output, "c:\\test\\") == 0);
+    return EXIT_SUCCESS;
+}