-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
73 lines (59 loc) · 2.3 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
import os
import re
from conan import ConanFile
from conan.tools.cmake import CMake
from conan.tools.files import load, copy, rmdir
class Recipe(ConanFile):
name = "metall-ffi"
version = None
author = "https://github.com/dice-group/metall-ffi"
url = "https://github.com/dice-group/metall-ffi"
description = "FFI for the metall libary"
topics = "FFI", "persistent memory"
# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_test_deps": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_test_deps": False,
}
exports_sources = "src/*", "CMakeLists.txt", "cmake/*", "LICENSE-APACHE", "LICENSE-MIT"
generators = "CMakeDeps", "CMakeToolchain"
def requirements(self):
self.requires("metall/0.28", transitive_headers=True)
if self.options.with_test_deps:
self.requires("doctest/2.4.11")
def set_version(self):
if not hasattr(self, 'version') or self.version is None:
cmake_file = load(self, os.path.join(self.recipe_folder, "CMakeLists.txt"))
self.version = re.search(r"project\([^)]*VERSION\s+(\d+\.\d+.\d+)[^)]*\)", cmake_file).group(1)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
_cmake = None
def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.configure()
return self._cmake
def build(self):
self._configure_cmake().build()
def package(self):
self._configure_cmake().install()
rmdir(self, os.path.join(self.package_folder, "cmake"))
rmdir(self, os.path.join(self.package_folder, "share"))
copy(self, "*LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
def package_info(self):
self.cpp_info.libs = ["metall-ffi"]
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", self.name)
self.cpp_info.set_property("cmake_target_name", f"{self.name}::{self.name}")
self.cpp_info.requires = [
"metall::metall",
]