-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconanfile.py
More file actions
112 lines (93 loc) · 3.39 KB
/
conanfile.py
File metadata and controls
112 lines (93 loc) · 3.39 KB
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
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, rm, rmdir
from conan.errors import ConanInvalidConfiguration
import os
required_conan_version = ">=2.0.9"
#
# INFO: Please, remove all comments before pushing your PR!
#
class ChronCppConan(ConanFile):
name = "chron-cpp"
version = "0.5.0"
description = "C++20 chron format scheduling library"
license = "Unlicense"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/BestITUserEUW/chron-cpp"
topics = ("chron",)
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
# In case having config_options() or configure() method, the logic should be moved to the specific methods.
implements = ["auto_shared_fpic"]
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
def layout(self):
cmake_layout(self, src_folder=".")
def validate(self):
if self.settings.compiler.get_safe("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 build_requirements(self):
self.tool_requires("cmake/[>=3.24]")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
copy(
self,
"LICENSE",
self.source_folder,
os.path.join(self.package_folder, "licenses"),
)
cmake = CMake(self)
cmake.install()
# Some files extensions and folders are not allowed. Please, read the FAQs to get informed.
# Consider disabling these at first to verify that the package_info() output matches the info exported by the project.
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "share"))
rm(self, "*.pdb", self.package_folder, recursive=True)
def package_info(self):
# library name to be packaged
self.cpp_info.libs = ["chron-cpp"]
self.cpp_info.set_property("cmake_file_name", "chron-cpp")
self.cpp_info.set_property("cmake_target_name", "oryx::chron-cpp")
@property
def _compilers_minimum_version(self):
return {
"gcc": "13",
"clang": "16",
"apple-clang": "15",
"msvc": "192",
}
@property
def _min_cppstd(self):
return "20"