-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
conanfile.py
75 lines (60 loc) · 2.42 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
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.files import get, copy
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc
import os
required_conan_version = ">=1.53.0"
class CtHashConan(ConanFile):
name = "cthash"
description = "constexpr implementation of SHA-2 and SHA-3 family of hashes"
license = "Apache-2.0"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/hanickadot/cthash/"
topics = ("constexpr", "xxhash", "sha", "header-only")
package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True
@property
def _min_cppstd(self):
return 20
@property
def _compilers_minimum_version(self):
return {
"gcc": "12.2",
"clang": "15.0.7",
"apple-clang": "14",
}
def layout(self):
basic_layout(self, src_folder="src")
def package_id(self):
self.info.clear()
def validate(self):
if is_msvc(self):
raise ConanInvalidConfiguration(f"{self.ref} doesn't support MSVC.")
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)
def loose_lt_semver(v1, v2):
lv1 = [int(v) for v in v1.split(".")]
lv2 = [int(v) for v in v2.split(".")]
min_length = min(len(lv1), len(lv2))
return lv1[:min_length] < lv2[:min_length]
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version):
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def package(self):
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
copy(
self,
pattern="*.hpp",
dst=os.path.join(self.package_folder, "include"),
src=os.path.join(self.source_folder, "include"),
)
def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []