/
conanfile.py
71 lines (59 loc) · 2.09 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
from conan import ConanFile, conan_version
from conan.tools.cmake import CMake, cmake_layout
class Autocheck(ConanFile):
name = 'autocheck'
version = '1.0.0'
user = 'github'
channel = 'thejohnfreeman'
license = 'ISC'
author = 'John Freeman <jfreeman08@gmail.com>'
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.0.0@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):
import json
import pathlib
path = pathlib.Path(self.recipe_folder) / 'cupcake.json'
with path.open('r') as file:
metadata = json.load(file)
methods = {
'tool': 'tool_requires',
'test': 'test_requires',
} if conan_version.major.value == 2 else {}
for requirement in 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})