-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
118 lines (94 loc) · 3.71 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from conan import ConanFile, tools
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
from conan.tools.files import files, get, copy, replace_in_file, collect_libs, rmdir, rm, apply_conandata_patches, export_conandata_patches
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.scm import Version
from conan.tools.build import check_min_cppstd
from conan.tools.microsoft import check_min_vs, is_msvc, is_msvc_static_runtime
import os
required_conan_version = ">=1.53.0"
class BcryptCpp(ConanFile):
name = "bcryptcpp"
version = "0.0.1"
description = "A c++ wrapper for libxcrypt around bcrypt password hashing"
license = "BSD-2-Clause"
topics = ("crypto", "bcrypt")
homepage = "https://github.com/xiadnoring/bcrypt-cpp"
url = "https://github.com/conan-io/conan-center-index"
package_type = "library"
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"min_cppstd": [14, 17, 20]
}
default_options = {
"shared": False,
"fPIC": True,
"min_cppstd": 17
}
exports_sources = "src/*", "include/*", "CMakeLists.txt", "LICENSE"
@property
def _min_cppstd(self):
return int(self.options.min_cppstd)
@property
def _compilers_minimum_version(self):
return {
"apple-clang": "10",
"clang": "7",
"gcc": "7",
"msvc": "191",
"Visual Studio": "15",
}
def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")
def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
def layout(self):
cmake_layout(self)
def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.variables["WITH_CONAN"] = True
tc.generate()
def requirements(self):
if int(self.options.min_cppstd) < 20:
self.requires("fmt/11.0.2")
def export_sources(self):
pass
#export_conandata_patches(self)
def _patch_sources(self):
apply_conandata_patches(self)
def build(self):
# self._patch_sources()
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()
copy(self, "LICENSE", src=os.path.join(self.source_folder), dst=os.path.join(self.package_folder, "licenses"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
fix_apple_shared_install_name(self)
def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", "bcryptcpp")
self.cpp_info.set_property("cmake_target_name", "bcryptcpp::bcryptcpp")
self.cpp_info.set_property("pkg_config_name", "bcryptcpp")
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs = ["dl", "m", "pthread"]
elif self.settings.os == "Windows":
self.cpp_info.system_libs = ["ws2_32", "shlwapi"]
self.cpp_info.libs = collect_libs(self)