-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* conanized zlib-ng 2.0.0 Signed-off-by: tkrupa <[email protected]> * removed win static lib suffix Signed-off-by: tkrupa <[email protected]> * conanized useful cmake options Signed-off-by: tkrupa <[email protected]> * Update recipes/zlib-ng/all/test_package/conanfile.py Test package following common template Co-authored-by: Chris Mc <[email protected]> * reduced test package Signed-off-by: tkrupa <[email protected]> * test_package depending on zlib.ng explicitely Signed-off-by: tkrupa <[email protected]> * using upstream cmake install Signed-off-by: tkrupa <[email protected]> * Update recipes/zlib-ng/all/test_package/test_package.c Co-authored-by: Uilian Ries <[email protected]> * using cmake wrapper Signed-off-by: tkrupa <[email protected]> * Improve zlib-ng Signed-off-by: Uilian Ries <[email protected]> * Update recipes/zlib-ng/all/conandata.yml Co-authored-by: Uilian Ries <[email protected]> * Update recipes/zlib-ng/config.yml Co-authored-by: Uilian Ries <[email protected]> * Update recipes/zlib-ng/all/test_package/test_package.c Co-authored-by: Uilian Ries <[email protected]> * Update recipes/zlib-ng/all/conanfile.py Co-authored-by: Chris Mc <[email protected]> * Update recipes/zlib-ng/all/test_package/CMakeLists.txt Co-authored-by: Chris Mc <[email protected]> * Update recipes/zlib-ng/all/conanfile.py Co-authored-by: Chris Mc <[email protected]> Co-authored-by: Chris Mc <[email protected]> Co-authored-by: Uilian Ries <[email protected]>
- Loading branch information
1 parent
e16b656
commit 3884c71
Showing
7 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 2.8.11) | ||
project(cmake_wrapper) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_subdirectory("source_subfolder") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"2.0.2": | ||
sha256: "dd37886f22ca6890e403ea6c1d60f36eab1d08d2f232a35f5b02126621149d28" | ||
url: "https://github.com/Dead2/zlib-ng/archive/2.0.2.tar.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"2.0.2": | ||
folder: all |