-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
80 lines (65 loc) · 2.95 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import os.path
import shutil
class QuaZipConan(ConanFile):
name = "quazip"
version="0.8.1"
license = "LGPL-2.1, zlib/png"
url = "https://github.com/vaerizk/quazip"
homepage = "https://github.com/stachenov/quazip"
description = "A C++ wrapper for Gilles Vollant's ZIP/UNZIP package (AKA Minizip) using Qt library"
topics = ("quazip", "conan-recipe")
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False]}
default_options = {
"shared": True,
"zlib:shared": False
}
generators = "cmake_paths"
exports_sources = [
"CMakeLists.txt",
os.path.join("quazip", "CMakeLists.txt"),
os.path.join("quazip", "quazip.rc.in"),
os.path.join("cmake", "quazip-config.cmake.in")
]
no_copy_source = True
_source_subdir_name = "source_subdir"
def configure(self):
if self.settings.os != "Windows":
raise ConanInvalidConfiguration("Only windows is supported at the moment")
def build_requirements(self):
self.build_requires("cmake/[>3.0.0]")
def requirements(self):
self.requires("qt/[5.12.7]@bincrafters/stable", private=False)
self.requires("zlib/1.2.11", private=False)
def source(self):
url = "https://github.com/stachenov/quazip/archive/v{}.zip".format(self.version)
tools.get(url)
os.rename("quazip-{}".format(self.version), self._source_subdir_name)
# replace CMakeLists
os.rename(
os.path.join(self._source_subdir_name, "CMakeLists.txt"),
os.path.join(self._source_subdir_name, "CMakeLists-original.txt")
)
shutil.copy("CMakeLists.txt", os.path.join(self._source_subdir_name, "CMakeLists.txt"))
os.rename(
os.path.join(self._source_subdir_name, "quazip", "CMakeLists.txt"),
os.path.join(self._source_subdir_name, "quazip", "CMakeLists-original.txt")
)
shutil.copy(os.path.join("quazip", "CMakeLists.txt"), os.path.join(self._source_subdir_name, "quazip", "CMakeLists.txt"))
shutil.copy(os.path.join("quazip", "quazip.rc.in"), os.path.join(self._source_subdir_name, "quazip", "quazip.rc.in"))
os.mkdir(os.path.join(self._source_subdir_name, "cmake"))
shutil.copy(os.path.join("cmake", "quazip-config.cmake.in"), os.path.join(self._source_subdir_name, "cmake"))
def build(self):
cmake = CMake(self)
cmake.definitions["VERSION"] = self.version
cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = os.path.join(self.build_folder, "conan_paths.cmake")
cmake.configure(source_folder=self._source_subdir_name)
cmake.build()
def package(self):
cmake = CMake(self)
cmake.configure(source_folder=self._source_subdir_name)
cmake.install()
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)