Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conanized zlib-ng 2.0.0 #5264

Merged
merged 17 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/zlib-ng/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"2.0.0":
sha256: "86993903527d9b12fc543335c19c1d33a93797b3d4d37648b5addae83679ecd8"
url: "https://github.com/Dead2/zlib-ng/archive/2.0.0.tar.gz"
tomas-krupa marked this conversation as resolved.
Show resolved Hide resolved
97 changes: 97 additions & 0 deletions recipes/zlib-ng/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
from conans import ConanFile, CMake
from conans.tools import download, unzip, replace_in_file, remove_files_by_mask, get
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):
get(**self.conan_data["sources"][self.version])
os.rename("zlib-ng-{}".format(self.version), self._source_subfolder)

def _configure_cmake(self):
if not self._cmake:
self._cmake = CMake(self)

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, source_folder=self._source_subfolder)
tomas-krupa marked this conversation as resolved.
Show resolved Hide resolved
return self._cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
for header in ["*zlib*.h", "*zconf*.h"]:
self.copy(pattern=header, dst="include", src=self._source_subfolder, keep_path=False)
self.copy(pattern=header, dst="include", src=self._build_subfolder, keep_path=False)
tomas-krupa marked this conversation as resolved.
Show resolved Hide resolved

if self.options.shared:
self.copy(pattern="*.dylib*", dst="lib", src=self._build_subfolder, keep_path=False, symlinks=True)
self.copy(pattern="*.so*", dst="lib", src=self._build_subfolder, keep_path=False, symlinks=True)
self.copy(pattern="*.dll", dst="bin", src=self._build_subfolder, keep_path=False)
self.copy(pattern="*.dll.a", dst="lib", src=self._build_subfolder, keep_path=False)
else:
self.copy(pattern="*.a", dst="lib", src=self._build_subfolder, keep_path=False)

self.copy(pattern="*.lib", dst="lib", src=self._build_subfolder, keep_path=False)
self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder)

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "ZLIB"
self.cpp_info.names["cmake_find_package_multi"] = "ZLIB"
tomas-krupa marked this conversation as resolved.
Show resolved Hide resolved

if self.settings.os == "Windows":
if self.settings.build_type == "Debug":
self.cpp_info.libs = ["zlib-ngd"]
else:
self.cpp_info.libs = ["zlib-ng"]

else:
self.cpp_info.libs = ["z-ng"]
10 changes: 10 additions & 0 deletions recipes/zlib-ng/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(ZLIB REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ZLIB::ZLIB)
tomas-krupa marked this conversation as resolved.
Show resolved Hide resolved
tomas-krupa marked this conversation as resolved.
Show resolved Hide resolved
17 changes: 17 additions & 0 deletions recipes/zlib-ng/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
Loading