-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
113 lines (89 loc) · 3.68 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import os
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
from conan.tools.build import check_min_cppstd
from conan.tools.files import copy
def _make_component_name(name):
return f"ka_{name}"
def _make_target_name(name):
return f"ka::{name}"
class TilecutRecipe(ConanFile):
name = "ka_tilecut"
version = "0.1.0"
license = "MIT"
author = "kononovarseniy@gmail.com"
url = "https://github.com/kononovarseniy/tilecut"
description = "Algorithms for cutting cartographic data into tiles"
settings = "os", "compiler", "build_type", "arch"
options = {
"build_tests": [True, False],
"build_generate_grid": [True, False],
}
default_options = {
"build_tests": True,
"build_generate_grid": True,
}
def export_sources(self):
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)
copy(self, "kononovarseniy/*", self.recipe_folder, self.export_sources_folder)
copy(self, "src/*", self.recipe_folder, self.export_sources_folder)
def requirements(self):
self.requires("fmt/9.1.0")
def build_requirements(self):
if self.options.build_tests:
self.test_requires("gtest/1.15.0")
if self.options.build_generate_grid:
self.requires("boost/1.86.0")
if self.options.build_tests or self.options.build_generate_grid:
self.requires("mpfr/4.2.1")
def validate(self):
check_min_cppstd(self, "20")
def layout(self):
cmake_layout(self)
def component_layout(name, path=None):
component_name = _make_component_name(name)
if path is None:
path = ["src", name]
# Configuration for editatable package.
self.cpp.source.components[component_name].includedirs = [os.path.join(*path, "include")]
self.cpp.build.components[component_name].libdirs = [os.path.join(*path)]
component_layout("common", ["kononovarseniy", "common"])
component_layout("geometry_types")
component_layout("exact")
component_layout("tilecut")
def generate(self):
deps = CMakeDeps(self)
deps.generate()
toolchain = CMakeToolchain(self)
toolchain.variables["BUILD_TESTS"] = bool(self.options.build_tests)
toolchain.variables["BUILD_GENERATE_GRID"] = bool(self.options.build_generate_grid)
toolchain.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
if self.options.build_tests:
cmake.test()
def package(self):
cmake = CMake(self)
cmake.install()
def package_info(self):
def component_info(name, kind, requires=[]):
component = self.cpp_info.components[_make_component_name(name)]
component.requires = list(map(_make_component_name, requires))
component.set_property("cmake_target_name", _make_target_name(name))
if kind == "header":
component.bindirs = []
component.libdirs = []
elif kind == "lib":
component.libs = [_make_component_name(name)]
elif kind == "bin":
pass
else:
assert False
component_info("common", kind="lib")
component_info("geometry_types", kind="header", requires=["common"])
component_info("exact", kind="lib", requires=["common", "geometry_types"])
component_info("tilecut", kind="lib", requires=["common", "geometry_types"])
if self.options.build_generate_grid:
component_info("generate_grid", kind="bin")