-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
88 lines (71 loc) · 2.63 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
from conan import ConanFile, conan_version
from conan.tools.cmake import CMake, cmake_layout
from functools import cached_property
import json
import pathlib
class Clrs(ConanFile):
@cached_property
def metadata(self):
path = pathlib.Path(self.recipe_folder) / 'cupcake.json'
if not path.is_file():
path = path.parent.parent / 'export_source' / 'cupcake.json'
with open(path, 'r') as file:
return json.load(file)
def set_name(self):
if self.name is None:
self.name = self.metadata['project']['name']
def set_version(self):
if self.version is None:
self.version = self.metadata['project']['version']
user = 'github'
channel = 'thejohnfreeman'
license = 'MIT'
author = 'John Freeman <jfreeman08@gmail.com>'
url = 'https://github.com/thejohnfreeman/clrs'
description = 'Data structures and algorithms from the CLRS book'
topics = ('data structure', 'algorithm', 'container', 'sort')
settings = 'os', 'compiler', 'build_type', 'arch'
options = {'shared': [True, False], 'fPIC': [True, False]}
default_options = {'shared': False, 'fPIC': True}
requires = [
# Available at https://conan.jfreeman.dev
'cupcake.cmake/1.1.1@github/thejohnfreeman',
]
generators = ['CMakeDeps', 'CMakeToolchain']
exports_sources = [
'CMakeLists.txt',
'cupcake.json',
'cmake/*',
'external/*',
'include/*',
'src/*',
]
# For out-of-source build.
# https://docs.conan.io/en/latest/reference/build_helpers/cmake.html#configure
no_copy_source = True
def layout(self):
cmake_layout(self)
def requirements(self):
methods = {
'tool': 'tool_requires',
'test': 'test_requires',
} if conan_version.major.value == 2 else {}
for requirement in self.metadata.get('imports', []):
groups = requirement.get('groups', [])
group = groups[0] if len(groups) == 1 else 'main'
method = methods.get(group, 'requires')
getattr(self, method)(requirement['reference'])
def config_options(self):
if self.settings.os == 'Windows':
del self.options.fPIC
def build(self):
cmake = CMake(self)
cmake.configure(variables={'BUILD_TESTING': 'NO'})
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()
def package_info(self):
path = f'{self.package_folder}/share/{self.name}/cpp_info.py'
with open(path, 'r') as file:
exec(file.read(), {}, {'self': self.cpp_info})