-
Notifications
You must be signed in to change notification settings - Fork 36
/
conanfile.py
417 lines (387 loc) · 18.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
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
from conans import ConanFile, CMake, tools
import os
class wxWidgetsConan(ConanFile):
name = "wxwidgets"
description = "wxWidgets is a C++ library that lets developers create applications for Windows, macOS, " \
"Linux and other platforms with a single code base."
topics = ("conan", "wxwidgets", "gui", "ui")
url = "https://github.com/bincrafters/conan-wxwidgets"
homepage = "https://www.wxwidgets.org"
license = "wxWidgets"
exports_sources = ["CMakeLists.txt", "patches/*"]
generators = ["cmake", "cmake_find_package"]
settings = "os", "arch", "compiler", "build_type"
_cmake = None
options = {"shared": [True, False],
"fPIC": [True, False],
"unicode": [True, False],
"compatibility": ["2.8", "3.0", "3.1"],
"zlib": ["off", "zlib"],
"png": ["off", "libpng"],
"jpeg": ["off", "libjpeg", "libjpeg-turbo", "mozjpeg"],
"tiff": ["off", "libtiff"],
"expat": ["off", "expat"],
"secretstore": [True, False],
"aui": [True, False],
"opengl": [True, False],
"html": [True, False],
"mediactrl": [True, False], # disabled by default as wxWidgets still uses deprecated GStreamer 0.10
"propgrid": [True, False],
"debugreport": [True, False],
"ribbon": [True, False],
"richtext": [True, False],
"sockets": [True, False],
"stc": [True, False],
"webview": [True, False],
"xml": [True, False],
"xrc": [True, False],
"cairo": [True, False],
"help": [True, False],
"html_help": [True, False],
"url": [True, False],
"protocol": [True, False],
"fs_inet": [True, False],
"custom_enables": "ANY", # comma splitted list
"custom_disables": "ANY"}
default_options = {
"shared": False,
"fPIC": True,
"unicode": True,
"compatibility": "3.0",
"zlib": "zlib",
"png": "libpng",
"jpeg": "libjpeg",
"tiff": "libtiff",
"expat": "expat",
"secretstore": True,
"aui": True,
"opengl": True,
"html": True,
"mediactrl": False,
"propgrid": True,
"debugreport": True,
"ribbon": True,
"richtext": True,
"sockets": True,
"stc": True,
"webview": True,
"xml": True,
"xrc": True,
"cairo": True,
"help": True,
"html_help": True,
"url": True,
"protocol": True,
"fs_inet": True,
"custom_enables": "",
"custom_disables": ""
}
_source_subfolder = "source_subfolder"
_build_subfolder = "build_subfolder"
def config_options(self):
if self.settings.os == 'Windows':
del self.options.fPIC
if self.settings.os != 'Linux':
self.options.remove('cairo')
def system_requirements(self):
if self.settings.os == 'Linux' and tools.os_info.is_linux:
if tools.os_info.with_apt:
installer = tools.SystemPackageTool()
packages = []
# TODO : GTK3
# packages.append('libgtk-3-dev')
if self.options.secretstore:
packages.append('libsecret-1-dev')
if self.options.webview:
packages.extend(['libsoup2.4-dev',
'libwebkitgtk-dev'])
# TODO : GTK3
# 'libwebkitgtk-3.0-dev'])
if self.options.mediactrl:
packages.extend(['libgstreamer0.10-dev',
'libgstreamer-plugins-base0.10-dev'])
if self.options.cairo:
packages.append('libcairo2-dev')
for package in packages:
installer.install(package)
def build_requirements(self):
self.build_requires("ninja/1.10.1")
def requirements(self):
if self.settings.os == 'Linux':
self.requires('xorg/system')
self.requires('gtk/system')
if self.options.opengl:
self.requires('opengl/system')
if self.options.png == 'libpng':
self.requires('libpng/1.6.37')
if self.options.jpeg == 'libjpeg':
self.requires('libjpeg/9d')
elif self.options.jpeg == 'libjpeg-turbo':
self.requires('libjpeg-turbo/2.0.6')
elif self.options.jpeg == 'mozjpeg':
self.requires('mozjpeg/3.3.1')
if self.options.tiff == 'libtiff':
self.requires('libtiff/4.0.9')
if self.options.zlib == 'zlib':
self.requires('zlib/1.2.11')
if self.options.expat == 'expat':
self.requires('expat/2.2.7')
def source(self):
tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)
def _configure_cmake(self):
if self._cmake:
return self._cmake
cmake = CMake(self)
# generic build options
cmake.definitions['wxBUILD_SHARED'] = self.options.shared
cmake.definitions['wxBUILD_SAMPLES'] = 'OFF'
cmake.definitions['wxBUILD_TESTS'] = 'OFF'
cmake.definitions['wxBUILD_DEMOS'] = 'OFF'
cmake.definitions['wxBUILD_INSTALL'] = True
cmake.definitions['wxBUILD_COMPATIBILITY'] = self.options.compatibility
if self.settings.compiler == 'clang':
cmake.definitions['wxBUILD_PRECOMP'] = 'OFF'
# platform-specific options
if self.settings.compiler == 'Visual Studio':
cmake.definitions['wxBUILD_USE_STATIC_RUNTIME'] = 'MT' in str(self.settings.compiler.runtime)
cmake.definitions['wxBUILD_MSVC_MULTIPROC'] = True
if self.settings.os == 'Linux':
# TODO : GTK3
cmake.definitions['wxBUILD_TOOLKIT'] = 'gtk2'
cmake.definitions['wxUSE_CAIRO'] = self.options.cairo
# Disable some optional libraries that will otherwise lead to non-deterministic builds
if self.settings.os != "Windows":
cmake.definitions['wxUSE_LIBSDL'] = 'OFF'
cmake.definitions['wxUSE_LIBICONV'] = 'OFF'
cmake.definitions['wxUSE_LIBNOTIFY'] = 'OFF'
cmake.definitions['wxUSE_LIBMSPACK'] = 'OFF'
cmake.definitions['wxUSE_LIBGNOMEVFS'] = 'OFF'
cmake.definitions['wxUSE_LIBPNG'] = 'sys' if self.options.png != 'off' else 'OFF'
cmake.definitions['wxUSE_LIBJPEG'] = 'sys' if self.options.jpeg != 'off' else 'OFF'
cmake.definitions['wxUSE_LIBTIFF'] = 'sys' if self.options.tiff != 'off' else 'OFF'
cmake.definitions['wxUSE_ZLIB'] = 'sys' if self.options.zlib != 'off' else 'OFF'
cmake.definitions['wxUSE_EXPAT'] = 'sys' if self.options.expat != 'off' else 'OFF'
# wxWidgets features
cmake.definitions['wxUSE_UNICODE'] = self.options.unicode
cmake.definitions['wxUSE_SECRETSTORE'] = self.options.secretstore
# wxWidgets libraries
cmake.definitions['wxUSE_AUI'] = self.options.aui
cmake.definitions['wxUSE_OPENGL'] = self.options.opengl
cmake.definitions['wxUSE_HTML'] = self.options.html
cmake.definitions['wxUSE_MEDIACTRL'] = self.options.mediactrl
cmake.definitions['wxUSE_PROPGRID'] = self.options.propgrid
cmake.definitions['wxUSE_DEBUGREPORT'] = self.options.debugreport
cmake.definitions['wxUSE_RIBBON'] = self.options.ribbon
cmake.definitions['wxUSE_RICHTEXT'] = self.options.richtext
cmake.definitions['wxUSE_SOCKETS'] = self.options.sockets
cmake.definitions['wxUSE_STC'] = self.options.stc
cmake.definitions['wxUSE_WEBVIEW'] = self.options.webview
cmake.definitions['wxUSE_XML'] = self.options.xml
cmake.definitions['wxUSE_XRC'] = self.options.xrc
cmake.definitions['wxUSE_HELP'] = self.options.help
cmake.definitions['wxUSE_WXHTML_HELP'] = self.options.html_help
cmake.definitions['wxUSE_URL'] = self.options.protocol
cmake.definitions['wxUSE_PROTOCOL'] = self.options.protocol
cmake.definitions['wxUSE_FS_INET'] = self.options.fs_inet
for item in str(self.options.custom_enables).split(","):
if len(item) > 0:
cmake.definitions[item] = True
for item in str(self.options.custom_disables).split(","):
if len(item) > 0:
cmake.definitions[item] = False
cmake.configure(build_folder=self._build_subfolder)
self._cmake = cmake
return self._cmake
def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
cmake = self._configure_cmake()
cmake.build()
def package(self):
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
# copy setup.h
self.copy(pattern='*setup.h', dst=os.path.join('include', 'wx'), src=os.path.join(self._build_subfolder, 'lib'),
keep_path=False)
if self.settings.os == 'Windows':
# copy wxrc.exe
self.copy(pattern='*', dst='bin', src=os.path.join(self._build_subfolder, 'bin'), keep_path=False)
else:
# make relative symlink
bin_dir = os.path.join(self.package_folder, 'bin')
for x in os.listdir(bin_dir):
filename = os.path.join(bin_dir, x)
if os.path.islink(filename):
target = os.readlink(filename)
if os.path.isabs(target):
rel = os.path.relpath(target, bin_dir)
os.remove(filename)
os.symlink(rel, filename)
def package_info(self):
version_tokens = self.version.split('.')
version_major = version_tokens[0]
version_minor = version_tokens[1]
version_suffix_major_minor = '-%s.%s' % (version_major, version_minor)
unicode = 'u' if self.options.unicode else ''
# wx no longer uses a debug suffix for non-windows platforms from 3.1.3 onwards
use_debug_suffix = False
if self.settings.build_type == 'Debug':
version_list = [int(part) for part in version_tokens]
use_debug_suffix = (self.settings.os == 'Windows' or version_list < [3, 1, 3])
debug = 'd' if use_debug_suffix else ''
if self.settings.os == 'Linux':
prefix = 'wx_'
toolkit = 'gtk2'
version = ''
suffix = version_suffix_major_minor
elif self.settings.os == 'Macos':
prefix = 'wx_'
toolkit = 'osx_cocoa'
version = ''
suffix = version_suffix_major_minor
elif self.settings.os == 'Windows':
toolkit = 'msw'
if self.settings.compiler == 'Visual Studio':
prefix = 'wx'
version = '%s%s' % (version_major, version_minor)
suffix = ''
else:
prefix = 'wx_'
version = ''
suffix = version_suffix_major_minor
def base_library_pattern(library):
return '{prefix}base{version}{unicode}{debug}_%s{suffix}' % library
def library_pattern(library):
return '{prefix}{toolkit}{version}{unicode}{debug}_%s{suffix}' % library
libs = []
if not self.options.shared:
regex_suffix = '{debug}' if self.settings.os == "Windows" else '{suffix}'
libs.append('wxregex{unicode}' + regex_suffix)
libs.append('{prefix}base{version}{unicode}{debug}{suffix}')
libs.append(library_pattern('core'))
libs.append(library_pattern('adv'))
if self.options.sockets:
libs.append(base_library_pattern('net'))
if self.options.xml:
libs.append(base_library_pattern('xml'))
if self.options.aui:
libs.append(library_pattern('aui'))
if self.options.opengl:
libs.append(library_pattern('gl'))
if self.options.html:
libs.append(library_pattern('html'))
if self.options.mediactrl:
libs.append(library_pattern('media'))
if self.options.propgrid:
libs.append(library_pattern('propgrid'))
if self.options.debugreport:
libs.append(library_pattern('qa'))
if self.options.ribbon:
libs.append(library_pattern('ribbon'))
if self.options.richtext:
libs.append(library_pattern('richtext'))
if self.options.stc:
if not self.options.shared:
scintilla_suffix = '{debug}' if self.settings.os == "Windows" else '{suffix}'
libs.append('wxscintilla' + scintilla_suffix)
libs.append(library_pattern('stc'))
if self.options.webview:
libs.append(library_pattern('webview'))
if self.options.xrc:
libs.append(library_pattern('xrc'))
for lib in reversed(libs):
self.cpp_info.libs.append(lib.format(prefix=prefix,
toolkit=toolkit,
version=version,
unicode=unicode,
debug=debug,
suffix=suffix))
self.cpp_info.defines.append('wxUSE_GUI=1')
if self.settings.build_type == 'Debug':
self.cpp_info.defines.append('__WXDEBUG__')
if self.options.shared:
self.cpp_info.defines.append('WXUSINGDLL')
if self.settings.os == 'Linux':
self.cpp_info.defines.append('__WXGTK__')
self.cpp_info.system_libs.extend(['dl', 'pthread', 'SM'])
elif self.settings.os == 'Macos':
self.cpp_info.defines.extend(['__WXMAC__', '__WXOSX__', '__WXOSX_COCOA__'])
for framework in ['Carbon',
'Cocoa',
'AudioToolbox',
'OpenGL',
'AVKit',
'AVFoundation',
'Foundation',
'IOKit',
'ApplicationServices',
'CoreText',
'CoreGraphics',
'CoreServices',
'CoreMedia',
'Security',
'ImageIO',
'System',
'WebKit',
'QuartzCore']:
self.cpp_info.frameworks.append(framework)
elif self.settings.os == 'Windows':
# see cmake/init.cmake
compiler_prefix = {'Visual Studio': 'vc',
'gcc': 'gcc',
'clang': 'clang'}.get(str(self.settings.compiler))
arch_suffix = '_x64' if self.settings.arch == 'x86_64' else ''
lib_suffix = '_dll' if self.options.shared else '_lib'
libdir = '%s%s%s' % (compiler_prefix, arch_suffix, lib_suffix)
libdir = os.path.join('lib', libdir)
self.cpp_info.bindirs.append(libdir)
self.cpp_info.libdirs.append(libdir)
self.cpp_info.defines.append('__WXMSW__')
# disable annoying auto-linking
self.cpp_info.defines.extend(['wxNO_NET_LIB',
'wxNO_XML_LIB',
'wxNO_REGEX_LIB',
'wxNO_ZLIB_LIB',
'wxNO_JPEG_LIB',
'wxNO_PNG_LIB',
'wxNO_TIFF_LIB',
'wxNO_ADV_LIB',
'wxNO_HTML_LIB',
'wxNO_GL_LIB',
'wxNO_QA_LIB',
'wxNO_XRC_LIB',
'wxNO_AUI_LIB',
'wxNO_PROPGRID_LIB',
'wxNO_RIBBON_LIB',
'wxNO_RICHTEXT_LIB',
'wxNO_MEDIA_LIB',
'wxNO_STC_LIB',
'wxNO_WEBVIEW_LIB'])
self.cpp_info.system_libs.extend(['kernel32',
'user32',
'gdi32',
'comdlg32',
'winspool',
'shell32',
'comctl32',
'ole32',
'oleaut32',
'imm32',
'uuid',
'wininet',
'rpcrt4',
'winmm',
'advapi32',
'wsock32'])
# Link a few libraries that are needed when using gcc on windows
if self.settings.compiler == 'gcc':
self.cpp_info.system_libs.extend(['uxtheme',
'version',
'shlwapi',
'oleacc'])
if self.settings.compiler == 'Visual Studio':
self.cpp_info.includedirs.append(os.path.join('include', 'msvc'))
else:
include_path = os.path.join("include", "wx{}".format(version_suffix_major_minor))
self.cpp_info.includedirs = [include_path] + self.cpp_info.includedirs