-
Notifications
You must be signed in to change notification settings - Fork 8
/
conanfile.py
114 lines (101 loc) · 3.51 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
from conans import ConanFile
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conans.tools import Git
import os
class XVIZ(ConanFile):
name = "xviz"
# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"build_tests": [True, False],
"build_examples": [True, False],
"coverage": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"build_tests": False,
"build_examples": False,
"coverage": False,
}
# Sources are located in the same place as this recipe, copy them to the recipe
exports_sources = (
"src/*",
"include/*",
"proto/*",
"cmake/*",
"CMakeLists.txt",
"README.md",
"LICENSE.md",
"tests/*",
"examples/*"
)
def _configure_cmake(self) -> CMake:
cmake = CMake(self)
variables = {"XVIZ_VERSION": f"{self.version}"}
if self.options.build_tests:
variables["XVIZ_BUILD_TESTS"] = "ON"
if self.options.build_examples:
variables["XVIZ_BUILD_EXAMPLES"] = "ON"
if self.options.coverage:
variables["XVIZ_TEST_COVERAGE"] = "ON"
cmake.configure(variables=variables)
return cmake
def set_version(self):
try:
if "XVIZ_CI_VERSION_OVERRIDE" in os.environ:
# this version is for local recipe consumer test
self.version = os.environ["XVIZ_CI_VERSION_OVERRIDE"]
else:
self.version = (
Git(folder=self.recipe_folder).run("describe --tags --abbr=0") or "0.0.1"
)
except:
# this version is for local recipe consumer test
self.version = "0.0.1"
def requirements(self):
self.requires("protobuf/3.21.9")
self.requires("fmt/9.1.0")
if self.options.build_tests:
self.requires("gtest/cci.20210126")
if self.options.build_examples:
self.requires("websocketpp/0.8.2")
self.requires("lodepng/cci.20200615")
self.options["websocketpp"].asio = "standalone"
# we don't need openssl for example
self.options["websocketpp"].with_openssl = False
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
self.options.coverage = False
else:
if not self.options.build_tests:
self.options.coverage = False
if self.settings.build_type != "Debug":
self.options.coverage = False
def layout(self):
cmake_layout(self)
def generate(self):
dp = CMakeDeps(self)
dp.generate()
tc = CMakeToolchain(self)
tc.generate()
def build(self):
cmake = self._configure_cmake()
if self.should_build or self.should_test:
cmake.build()
if self.options.build_tests and self.should_test:
if self.settings.os == "Windows":
cmake.test()
else:
cmake.test(cli_args=["ARGS=-V"])
def package(self):
cmake = CMake(self)
cmake.install()
def package_info(self):
self.cpp_info.libs = ["xviz"]
# We will use our installed cmake files
self.cpp_info.set_property("cmake_find_mode", "none")
self.cpp_info.builddirs.append(os.path.join("lib", "cmake", "xviz"))