-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconanfile.py
More file actions
117 lines (90 loc) · 4.57 KB
/
Copy pathconanfile.py
File metadata and controls
117 lines (90 loc) · 4.57 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.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
class rsltestRecipe(ConanFile):
name = "rsl-test"
version = "0.1"
package_type = "library"
# Optional metadata
license = "<Put the package license here>"
author = "<Put your name here> <And your email here>"
url = "<Package recipe repository url here, for issues about the package>"
description = "<Description of mypkg package here>"
topics = ("<Put some tag here>", "<here>", "<and here>")
# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False], "fPIC": [True, False],
"coverage": [True, False],
"examples": [True, False],
"editable": [True, False]
}
default_options = {"shared": True, "fPIC": True, "coverage": False, "examples": False, "editable": False}
# Sources are located in the same place as this recipe, copy them to the recipe
exports_sources = "CMakeLists.txt", "src/*", "include/*", "example/*", "test/*"
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 requirements(self):
self.requires("libassert/dev", transitive_headers=True, transitive_libs=True, options={"shared": True})
self.requires("rsl-util/0.1", transitive_headers=True, transitive_libs=True)
self.requires("rsl-config/0.1", transitive_headers=False, transitive_libs=True)
self.requires("rsl-xml/0.1", transitive_headers=False, transitive_libs=True)
self.requires("nlohmann_json/3.12.0", transitive_headers=True, transitive_libs=True)
def layout(self):
cmake_layout(self)
def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.generate()
def build(self):
cmake = CMake(self)
cmake.configure(variables={
"ENABLE_COVERAGE": self.options.coverage,
"BUILD_EXAMPLES": self.options.examples,
"BUILD_TESTING": not self.conf.get("tools.build:skip_test", default=False)
})
cmake.build()
if self.options.editable:
# package is in editable mode - make sure it's installed after building
cmake.install()
def package(self):
cmake = CMake(self)
cmake.install()
def package_info(self):
self.cpp_info.set_property("cmake_file_name", "rsl-test")
test = self.cpp_info.components["test"]
test.set_property("cmake_target_name", "rsl::test")
test.includedirs = ["include"]
test.libdirs = ["lib"]
test.requires = ["libassert::assert", "rsl-util::util"]
test.libs = ["rsltest"]
test_main = self.cpp_info.components["test_main"]
test_main.set_property("cmake_target_name", "rsl::test_main")
test_main.includedirs = ["include"]
test_main.libdirs = ["lib"]
test_main.requires = ["test", "rsl-config::config", "rsl-xml::xml"]
test_main.libs = ["rsltest_main"]
if str(self.settings.compiler) == "clang":
test_cov = self.cpp_info.components["test_cov"]
test_cov.set_property("cmake_target_name", "rsl::test_cov")
test_cov.libs = []
test_cov.sources = ["ext/coverage_hooks.cpp"]
test_cov.cxxflags = ["-fsanitize-coverage=pc-table,trace-pc-guard"]
test_cov.sharedlinkflags = ["-fsanitize-coverage=pc-table,trace-pc-guard"]
test_cov.exelinkflags = ["-fsanitize-coverage=pc-table,trace-pc-guard"]
test_cov.requires = []
test_cov_flags = self.cpp_info.components["test_cov_flags"]
test_cov_flags.set_property("cmake_target_name", "rsl::test_cov_flags")
test_cov_flags.cxxflags = ["-fsanitize-coverage=pc-table,trace-pc-guard"]
test_cov_flags.sharedlinkflags = ["-fsanitize-coverage=pc-table,trace-pc-guard"]
test_cov_flags.exelinkflags = ["-fsanitize-coverage=pc-table,trace-pc-guard"]
test_cov_hooks = self.cpp_info.components["test_cov_hooks"]
test_cov_hooks.set_property("cmake_target_name", "rsl::test_cov_hooks")
test_cov_hooks.sources = ["ext/coverage_hooks.cpp"]
# test_cov = self.cpp_info.components["test_cov"]
# test_cov.set_property("cmake_target_name", "rsl::test_cov")
# test_cov.requires = ["test_cov_flags", "test_cov_hooks"]