This repository has been archived by the owner on Sep 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
conanfile.py
265 lines (231 loc) · 10.1 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from conans import ConanFile, CMake, tools
import os
class LibnameConan(ConanFile):
name = "magnum"
version = "2018.10"
description = "Magnum — Lightweight and modular C++11/C++14 \
graphics middleware for games and data visualization"
# topics can get used for searches, GitHub topics, Bintray tags etc. Add here keywords about the library
topics = ("conan", "corrade", "graphics", "rendering", "3d", "2d", "opengl")
url = "https://github.com/helmesjo/conan-magnum"
homepage = "https://magnum.graphics"
author = "helmesjo <helmesjo@gmail.com>"
license = "MIT" # Indicates license type of the packaged library; please use SPDX Identifiers https://spdx.org/licenses/
exports = ["LICENSE.md"]
exports_sources = ["CMakeLists.txt"]
generators = "cmake"
short_paths = True # Some folders go out of the 260 chars path length scope (windows)
# Options may need to change depending on the packaged library.
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"build_deprecated": [True, False],
"build_multithreaded": [True, False],
"build_plugins_static": [True, False],
"build_tests": [True, False],
"target_gl": [True, False],
"target_gles": [True, False],
"with_anyaudioimporter": [True, False],
"with_anyimageconverter": [True, False],
"with_anyimageimporter": [True, False],
"with_anysceneimporter": [True, False],
"with_audio": [True, False],
"with_debugtools": [True, False],
"with_distancefieldconverter": [True, False],
"with_eglcontext": [True, False],
"with_fontconverter": [True, False],
"with_glfwapplication": [True, False],
"with_glutapplication": [True, False],
"with_glxapplication": [True, False],
"with_glxcontext": [True, False],
"with_gl_info": [True, False],
"with_imageconverter": [True, False],
"with_magnumfont": [True, False],
"with_magnumfontconverter": [True, False],
"with_meshtools": [True, False],
"with_objimporter": [True, False],
"with_opengltester": [True, False],
"with_primitives": [True, False],
"with_scenegraph": [True, False],
"with_sdl2application": [True, False],
"with_shaders": [True, False],
"with_shapes": [True, False],
"with_text": [True, False],
"with_tgaimageconverter": [True, False],
"with_tgaimporter": [True, False],
"with_vk": [True, False],
"with_wavaudioimporter": [True, False],
"with_windowlesseglapplication": [True, False],
"with_windowlessglxapplication": [True, False],
"with_xeglapplication": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"build_deprecated": False,
"build_multithreaded": True,
"build_plugins_static": False,
"build_tests": False,
"target_gl": True,
"target_gles": False,
"with_anyaudioimporter": False,
"with_anyimageconverter": False,
"with_anyimageimporter": False,
"with_anysceneimporter": False,
"with_audio": False,
"with_debugtools": True,
"with_distancefieldconverter": False,
"with_eglcontext": False,
"with_fontconverter": False,
"with_glfwapplication": False,
"with_glutapplication": False,
"with_glxapplication": False,
"with_glxcontext": False,
"with_gl_info": False,
"with_imageconverter": False,
"with_magnumfont": False,
"with_magnumfontconverter": False,
"with_meshtools": True,
"with_objimporter": False,
"with_opengltester": False,
"with_primitives": True,
"with_scenegraph": True,
"with_sdl2application": True,
"with_shaders": True,
"with_shapes": False,
"with_text": True,
"with_tgaimageconverter": False,
"with_tgaimporter": False,
"with_vk": False,
"with_wavaudioimporter": False,
"with_windowlesseglapplication": False,
"with_windowlessglxapplication": False,
"with_xeglapplication": False,
}
# Custom attributes for Bincrafters recipe conventions
_source_subfolder = "source_subfolder"
_build_subfolder = "build_subfolder"
requires = (
"corrade/2018.10@helmesjo/stable"
)
def system_package_architecture(self):
if tools.os_info.with_apt:
if self.settings.arch == "x86":
return ':i386'
elif self.settings.arch == "x86_64":
return ':amd64'
elif self.settings.arch == "armv6" or self.settings.arch == "armv7":
return ':armel'
elif self.settings.arch == "armv7hf":
return ':armhf'
elif self.settings.arch == "armv8":
return ':arm64'
if tools.os_info.with_yum:
if self.settings.arch == "x86":
return '.i686'
elif self.settings.arch == 'x86_64':
return '.x86_64'
return ""
def system_requirements(self):
# Install required OpenGL stuff on linux
if tools.os_info.is_linux:
if tools.os_info.with_apt:
installer = tools.SystemPackageTool()
packages = []
if self.options.target_gl:
packages.append("libgl1-mesa-dev")
if self.options.target_gles:
packages.append("libgles1-mesa-dev")
arch_suffix = self.system_package_architecture()
for package in packages:
installer.install("%s%s" % (package, arch_suffix))
elif tools.os_info.with_yum:
installer = tools.SystemPackageTool()
arch_suffix = self.system_package_architecture()
packages = []
if self.options.target_gl:
packages.append("mesa-libGL-devel")
if self.options.target_gles:
packages.append("mesa-libGLES-devel")
for package in packages:
installer.install("%s%s" % (package, arch_suffix))
else:
self.output.warn("Could not determine package manager, skipping Linux system requirements installation.")
def config_options(self):
if self.settings.os == 'Windows':
del self.options.fPIC
if self.options.build_tests:
self.options.with_testsuite = True
def configure(self):
self.options['corrade'].add_option('build_deprecated', self.options.build_deprecated)
def requirements(self):
if self.options.with_sdl2application:
self.requires("sdl2/2.0.8@bincrafters/stable")
def source(self):
source_url = "https://github.com/mosra/magnum"
tools.get("{0}/archive/v{1}.tar.gz".format(source_url, self.version))
extracted_dir = self.name + "-" + self.version
# Rename to "source_subfolder" is a convention to simplify later steps
os.rename(extracted_dir, self._source_subfolder)
def _configure_cmake(self):
cmake = CMake(self)
def add_cmake_option(option, value):
var_name = "{}".format(option).upper()
value_str = "{}".format(value)
var_value = "ON" if value_str == 'True' else "OFF" if value_str == 'False' else value_str
cmake.definitions[var_name] = var_value
for attr, _ in self.options.iteritems():
value = getattr(self.options, attr)
add_cmake_option(attr, value)
add_cmake_option("BUILD_STATIC", not self.options.shared)
add_cmake_option("BUILD_STATIC_PIC", not self.options.shared and self.options.get_safe("fPIC"))
cmake.configure(build_folder=self._build_subfolder)
return cmake
def build(self):
cmake = self._configure_cmake()
cmake.build()
# Fix later. Currently root contains no tests, and source_subfolder fails to run the test (can't find executables)
# if self.options.build_tests:
# self.output.info("Running {} tests".format(self.name))
# source_path = os.path.join(self._build_subfolder, self._source_subfolder)
# with tools.chdir(source_path):
# self.run("ctest --build-config {}".format(self.settings.build_type))
def package(self):
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
# If the CMakeLists.txt has a proper install method, the steps below may be redundant
# If so, you can just remove the lines below
include_folder = os.path.join(self._source_subfolder, "include")
self.copy(pattern="*", dst="include", src=include_folder)
self.copy(pattern="*.dll", dst="bin", keep_path=False)
self.copy(pattern="*.lib", dst="lib", keep_path=False)
self.copy(pattern="*.a", dst="lib", keep_path=False)
self.copy(pattern="*.so*", dst="lib", keep_path=False)
self.copy(pattern="*.dylib", dst="lib", keep_path=False)
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
# Filter out Magnum and readd last,
# making sure linked order is correct.
libs = self.cpp_info.libs
if self.settings.build_type == "Debug":
magnumLib = "Magnum-d"
else:
magnumLib = "Magnum"
libs = [lib for lib in libs if magnumLib != lib]
libs.append(magnumLib)
self.cpp_info.libs = libs
if self.settings.os == "Windows":
if self.settings.compiler == "Visual Studio":
if not self.options.shared:
self.cpp_info.libs.append("OpenGL32.lib")
else:
self.cpp_info.libs.append("opengl32")
else:
if self.settings.os == "Macos":
self.cpp_info.exelinkflags.append("-framework OpenGL")
elif not self.options.shared:
self.cpp_info.libs.append("GL")