forked from Ultimaker/libnest2d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
87 lines (74 loc) · 2.98 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
from pathlib import Path
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake
from conans.errors import ConanInvalidConfiguration
from conans.tools import Version
from conan.tools.files import files
required_conan_version = ">=1.46.2"
class Libnest2DConan(ConanFile):
name = "libnest2d"
description = "2D irregular bin packaging and nesting library written in modern C++"
topics = ("conan", "cura", "prusaslicer", "nesting", "c++", "bin packaging")
settings = "os", "compiler", "build_type", "arch"
build_policy = "missing"
options = {
"shared": [True, False],
"fPIC": [True, False],
"tests": [True, False],
"header_only": [True, False],
"geometries": ["clipper", "boost", "eigen"],
"optimizer": ["nlopt", "optimlib"],
"threading": ["std", "tbb", "omp", "none"]
}
default_options = {
"shared": True,
"tests": False,
"fPIC": True,
"header_only": False,
"geometries": "clipper",
"optimizer": "nlopt",
"threading": "std"
}
scm = {
"type": "git",
"subfolder": ".",
"url": "auto",
"revision": "auto"
}
def configure(self):
if self.options.shared or self.settings.compiler == "Visual Studio":
del self.options.fPIC
if self.options.geometries == "clipper":
self.options["clipper"].shared = self.options.shared
self.options["boost"].shared = self.options.shared
if self.options.optimizer == "nlopt":
self.options["nlopt"].shared = self.options.shared
def build_requirements(self):
if self.options.tests:
self.build_requires("catch2/2.13.6", force_host_context=True)
def requirements(self):
if self.options.geometries == "clipper":
self.requires("clipper/6.4.2")
self.requires("boost/1.78.0")
elif self.options.geometries == "eigen":
self.requires("eigen/3.3.7")
if self.options.optimizer == "nlopt":
self.requires("nlopt/2.7.0")
def generate(self):
cmake = CMakeDeps(self)
cmake.generate()
tc = CMakeToolchain(self)
# Don't use Visual Studio as the CMAKE_GENERATOR
if self.settings.compiler == "Visual Studio":
tc.blocks["generic_system"].values["generator_platform"] = None
tc.blocks["generic_system"].values["toolset"] = None
tc.variables["LIBNEST2D_HEADER_ONLY"] = self.options.header_only
if self.options.header_only:
tc.variables["BUILD_SHARED_LIBS"] = False
else:
tc.variables["BUILD_SHARED_LIBS"] = self.options.shared
tc.variables["LIBNEST2D_BUILD_UNITTESTS"] = self.options.tests
tc.variables["LIBNEST2D_GEOMETRIES"] = self.options.geometries
tc.variables["LIBNEST2D_OPTIMIZER"] = self.options.optimizer
tc.variables["LIBNEST2D_THREADING"] = self.options.threading
tc.generate()