-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathSConscript.configure
86 lines (71 loc) · 2.89 KB
/
SConscript.configure
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
Import('env')
# Define Custom configure checks ---------------------------------------------
def CheckBoostVersion(context, version):
'''Check if Boost Library is at least of specified version
'''
# Boost versions are in format major.minor.subminor
v_arr = [int(n) for n in version.split(".")]
version_n = sum([(v * n) for v, n in zip(v_arr, (1e5, 1e2, 1))])
context.Message('Checking for Boost version >= %s... ' % (version))
rv = context.TryCompile('\n'.join([
'#include <boost/version.hpp>',
'#if BOOST_VERSION < %d',
'#error Installed boost is too old!',
'#endif',
'int main() { return 0; }',
'', ]) % version_n, '.cpp')
context.Result(rv)
return rv
def CheckBoostSerialization(context):
context.Message('Checking for boost_serialization... ')
test_code = '''
#include <boost/serialization/serialization.hpp>
int main() { return 0; }
'''
rv = context.TryCompile(test_code, '.cpp')
context.Result(rv)
return rv
# Helper functions -----------------------------------------------------------
boostlibtags = ['', '-mt']
def configure_boost_library(libname):
'''Add a boost library to the configured environment allowing for any
of the boostlibtags name extensions.
libname -- boost library name without any extension
Note: CheckLib function automatically adds library to the environment.
'''
# using global conf defined below
for t in boostlibtags:
libnamefull = libname + t
if conf.CheckLib(libnamefull, language='C++'):
boostlibtags[:] = [t]
return
# library not found here
print('This program requires %r library' % libname)
Exit(1)
# Start configuration --------------------------------------------------------
conf = Configure(env, custom_tests={
'CheckBoostVersion' : CheckBoostVersion,
'CheckBoostSerialization': CheckBoostSerialization
})
# serialization of unordered_map requires boost 1.56.0
boost_required = '1.56.0'
if not conf.CheckBoostVersion(boost_required):
print('This software requires Boost %s or later.' % boost_required)
Exit(1)
if not conf.CheckBoostSerialization():
print('Boost.Serialization library not found!')
Exit(1)
# ObjCryst - assume a no-objcryst fallback configuration.
conf.env['has_objcryst'] = False
# Detect ObjCryst and exit with error if requested and not found.
# By default conf.env does not contain the 'enable_objcryst' key.
if conf.env.get('enable_objcryst', True):
conf.env['has_objcryst'] = conf.CheckLibWithHeader(
'ObjCryst', 'ObjCryst/ObjCryst/Crystal.h',
language='C++', autoadd=True)
objcryst_requested = conf.env.get('enable_objcryst', False)
if objcryst_requested and not conf.env['has_objcryst']:
print("Adjust compiler paths or build with 'enable_objcryst=False'.")
Exit(1)
env = conf.Finish()
# vim: ft=python