-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathconanfile.py
91 lines (77 loc) · 2.72 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
# mypy: ignore-errors
# pylint: skip-file
from pathlib import Path
from conan import ConanFile
from conan.tools import cmake, files, scm
required_conan_version = ">=1.52.0"
class CloeModels(ConanFile):
name = "cloe-models"
url = "https://github.com/eclipse/cloe"
description = "Cloe experimental standard data models"
license = "Apache-2.0"
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"pedantic": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"pedantic": True,
}
generators = "CMakeDeps", "VirtualRunEnv"
no_copy_source = True
exports_sources = [
"include/*",
"src/*",
"CMakeLists.txt",
]
def set_version(self):
version_file = Path(self.recipe_folder) / "../VERSION"
if version_file.exists():
self.version = files.load(self, version_file).strip()
else:
git = scm.Git(self, self.recipe_folder)
self.version = git.run("describe --dirty=-dirty")[1:]
def requirements(self):
self.requires(f"cloe-runtime/{self.version}@cloe/develop")
self.requires("boost/1.74.0")
self.requires("eigen/3.4.0")
self.requires("sol2/3.3.1")
def build_requirements(self):
self.test_requires("gtest/1.14.0")
def layout(self):
cmake.cmake_layout(self)
def generate(self):
tc = cmake.CMakeToolchain(self)
tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True
tc.cache_variables["CLOE_PROJECT_VERSION"] = self.version
tc.cache_variables["TargetLintingExtended"] = self.options.pedantic
tc.generate()
def build(self):
cm = cmake.CMake(self)
if self.should_configure:
cm.configure()
if self.should_build:
cm.build()
if self.should_test:
cm.test()
def package(self):
cm = cmake.CMake(self)
if self.should_install:
cm.install()
def package_id(self):
self.info.requires["boost"].full_package_mode()
del self.info.options.pedantic
def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", "cloe-models")
self.cpp_info.set_property("cmake_target_name", "cloe::models")
self.cpp_info.set_property("pkg_config_name", "cloe-models")
# Make sure we can find the library, both in editable mode and in the
# normal package mode:
if not self.in_local_cache:
self.cpp_info.libs = ["cloe-models"]
else:
self.cpp_info.libs = files.collect_libs(self)