-
Notifications
You must be signed in to change notification settings - Fork 266
Expand file tree
/
Copy pathconanfile.py
More file actions
95 lines (79 loc) · 3 KB
/
Copy pathconanfile.py
File metadata and controls
95 lines (79 loc) · 3 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
import os
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import copy, rmdir
required_conan_version = ">=2.28"
class TgBotCppConan(ConanFile):
name = "tgbot-cpp"
description = "C++ library for Telegram Bot API"
license = "MIT"
url = "https://github.com/reo7sp/tgbot-cpp"
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_tests": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_tests": False,
}
exports_sources = (
"CMakeLists.txt",
"LICENSE",
"cmake/*",
"include/*",
"src/*",
"tests/*",
)
def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
def layout(self):
cmake_layout(self)
def requirements(self):
self.requires("boost/[>=1.83.0 <1.90.0]", options={"header_only": True}, transitive_headers=True)
self.requires("libcurl/[>=7.78 <9]", transitive_headers=True, transitive_libs=True)
self.requires("nlohmann_json/3.12.0", transitive_headers=True)
def build_requirements(self):
self.tool_requires("cmake/[>=3.16]")
if self.options.with_tests:
self.test_requires("gtest/1.17.0")
def validate(self):
check_min_cppstd(self, 20)
def generate(self):
toolchain = CMakeToolchain(self)
toolchain.variables["ENABLE_TESTS"] = bool(self.options.with_tests)
toolchain.generate()
dependencies = CMakeDeps(self)
dependencies.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
if self.options.with_tests:
cmake.ctest(cli_args=["--output-on-failure"])
def package(self):
cmake = CMake(self)
cmake.install()
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
def package_info(self):
self.cpp_info.libs = ["TgBot"]
self.cpp_info.set_property("cmake_file_name", "TgBot")
self.cpp_info.set_property("cmake_target_name", "TgBot::TgBot")
self.cpp_info.set_property("cmake_target_aliases", ["tgbot::tgbot"])
if self.options.shared:
self.cpp_info.defines.append("TGBOT_DLL")
if self.settings.os == "Windows":
self.cpp_info.defines.extend(["_WIN32_WINNT=0x0601", "WIN32_LEAN_AND_MEAN", "NOMINMAX"])
if not self.options.shared:
self.cpp_info.system_libs.append("ws2_32")
elif self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("pthread")