forked from sagemath/sage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeson.build
More file actions
283 lines (268 loc) · 8.76 KB
/
meson.build
File metadata and controls
283 lines (268 loc) · 8.76 KB
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
# Compilers
cc = meson.get_compiler('c')
cpp = meson.get_compiler('cpp')
cython = meson.get_compiler('cython')
# Setup dependencies that are needed by many modules
numpy = dependency('numpy', required: false, version: '>=2.2.4')
if not numpy.found()
# Older versions of numpy don't have a pkg-config file
inc_numpy = run_command(
py,
[
'-c',
'''
from os.path import relpath
import numpy
path = numpy.get_include()
try:
print(relpath(path))
except Exception:
print(path)
'''.strip(),
],
check: true,
).stdout().strip()
numpy = declare_dependency(include_directories: inc_numpy)
endif
inc_cysignals = run_command(
py,
[
'-c',
'''
from os.path import relpath
import cysignals
path = cysignals.__file__.replace('__init__.py', '')
try:
print(relpath(path))
except Exception:
print(path)
'''.strip(),
],
check: true,
).stdout().strip()
cysignals = declare_dependency(include_directories: inc_cysignals)
inc_gmpy2 = run_command(
py,
[
'-c',
'''
from os.path import relpath
import gmpy2
path = gmpy2.__file__.replace('__init__.py', '')
try:
print(relpath(path))
except Exception:
print(path)
'''.strip(),
],
check: true,
).stdout().strip()
gmpy2 = declare_dependency(include_directories: inc_gmpy2)
gmp = dependency('gmp')
if is_windows
# Not yet available on Windows
cypari2 = disabler()
else
inc_cypari2 = run_command(
py,
[
'-c',
'''
from os.path import relpath
import cypari2
path = cypari2.__file__.replace('__init__.py', '')
try:
print(relpath(path))
except Exception:
print(path)
'''.strip(),
],
check: true,
).stdout().strip()
cypari2 = declare_dependency(include_directories: inc_cypari2)
endif
# Cannot be found via pkg-config
pari = cc.find_library('pari', required: not is_windows, disabler: true)
mpfr = dependency('mpfr')
if is_windows
# TODO: Reenable the following once conda's python is fixed
# https://github.com/conda-forge/python-feedstock/pull/770
# # In its currently released version, flint is not working on Windows; thus always use subproject
# #flint = dependency('flint', version: '>=3.1.3')
# cmake = import('cmake')
# cmake_opts = cmake.subproject_options()
# cmake_opts.add_cmake_defines({'BUILD_SHARED_LIBS': 'OFF'})
# flint_proj = cmake.subproject('flint', options: cmake_opts)
# flint = flint_proj.dependency('flint')
# meson.override_dependency('flint', flint)
flint = disabler()
else
flint = dependency('flint', version: '>=3.0.0')
if flint.version().version_compare('<3.1')
# In older versions of flint, pkg-config file is broken, so we manually use find_library
# This has been fixed in flint v3.1: https://github.com/flintlib/flint/pull/1647
flint = cc.find_library('flint')
endif
endif
blas_order = []
if host_machine.system() == 'darwin'
blas_order += 'accelerate'
endif
if host_machine.cpu_family() == 'x86_64'
blas_order += 'mkl'
endif
# pkg-config uses a lower-case name while CMake uses a capitalized name, so try
# that too to make the fallback detection with CMake work
blas_order += ['cblas', 'openblas', 'OpenBLAS', 'flexiblas', 'blis', 'blas']
blas = dependency(blas_order)
if is_windows
# pkg-config file is wrong on Windows (https://github.com/conda-forge/gsl-feedstock/issues/63)
gsl = cc.find_library('gsl', required: false, disabler: true)
else
gsl = dependency('gsl', version: '>=2.5')
endif
gd = dependency('gdlib', required: false, version: '>=2.1')
if not gd.found()
# Doesn't have a pkg-config file on some systems (https://github.com/conda-forge/libgd-feedstock/issues/55)
gd = cc.find_library('gd', required: not is_windows, disabler: true)
endif
# Only some platforms have a standalone math library (https://mesonbuild.com/howtox.html#add-math-library-lm-portably)
m = cc.find_library('m', required: false)
m4ri = dependency('m4ri', version: '>=20250128', required: false)
if not m4ri.found()
# Older versions of m4ri are declaring "@SIMD_CFLAGS@" as compile_args
# which breaks the build. So we exclude these compile args.
# https://github.com/malb/m4ri/commit/3197be5f7d3c67e8f13e32516557f35cbf4ff6ce
m4ri = dependency('m4ri', version: '>=20140914').partial_dependency(
includes: true,
link_args: true,
links: true,
sources: true,
)
endif
m4rie = dependency('m4rie', required: false)
if not m4rie.found()
# For some reason, m4rie is not found via pkg-config on some systems (eg Conda)
m4rie = cc.find_library('m4rie', required: not is_windows, disabler: true)
endif
mtx = dependency('libmtx', required: false)
if not mtx.found()
# fallback for older versions without pkg-config
mtx = cc.find_library(
'mtx',
required: get_option('meataxe'),
disabler: true,
has_headers: ['meataxe.h'],
)
endif
png = dependency(['libpng', 'png', 'png16'], version: '>=1.2')
zlib = dependency('zlib', version: '>=1.2.11')
# We actually want >= 20250122, but the version number is not updated in the pkgconfig
# https://github.com/conda-forge/eclib-feedstock/issues/48
# To old versions of eclib don't ship a pkg-config file, so this should be rather safe
ec = dependency(
'eclib',
version: '>=20231211',
required: get_option('eclib'),
disabler: true,
)
ecm = cc.find_library('ecm', required: not is_windows, disabler: true)
gmpxx = dependency('gmpxx', required: not is_windows, disabler: true)
fflas = dependency(
'fflas-ffpack',
required: not is_windows,
disabler: true,
version: '>=2.5.0',
)
givaro = dependency(
'givaro',
required: not is_windows,
disabler: true,
version: '>=4.2.0',
)
linbox = dependency('linbox', required: false, version: '>=1.7.0')
if not linbox.found()
linbox = cc.find_library('linbox', required: not is_windows, disabler: true)
endif
mpc = cc.find_library('mpc', required: not is_windows, disabler: true)
mpfi = cc.find_library('mpfi', required: false)
if not mpfi.found()
mpfi_proj = subproject('mpfi')
mpfi = mpfi_proj.get_variable('mpfi_dep')
endif
gap = dependency('libgap', version: '>=4.13.0', required: false)
if not gap.found()
# Fallback in case pkg-config info is not available
# Test for common.h header that was added in 4.12 as a indirect version check
gap = cc.find_library(
'gap',
has_headers: ['gap/common.h'],
required: not is_windows,
disabler: true,
)
endif
singular = dependency('Singular', required: not is_windows, disabler: true)
singular_factory = disabler()
if singular.found()
singular_factory = singular
else
singular_proj = subproject('singular')
singular_factory = singular_proj.get_variable('factory_dep')
endif
# Cannot be found via pkg-config
ntl = cc.find_library('ntl', required: not is_windows, disabler: true)
boost_cpp17_compatible = false
boost = dependency(
'boost',
version: '>=1.83.0',
required: false,
modules: ['graph'],
)
if boost.found()
# Need at least v1.83.0 (https://github.com/boostorg/functional/commit/6a573e4b8333ee63ee62ce95558c3667348db233)
# for C++17 compatibility.
boost_cpp17_compatible = true
else
boost = dependency(
'boost',
version: '>=1.66.0',
required: false,
modules: ['graph'],
)
endif
# Meson currently ignores include_directories for Cython modules, so we
# have to add them manually.
# https://github.com/mesonbuild/meson/issues/9562
add_project_arguments('-I', meson.current_source_dir(), language: 'cython')
add_project_arguments('-I', meson.current_build_dir(), language: 'cython')
# Add global compiler flags
add_project_arguments('-X auto_pickle=False', language: 'cython')
add_project_arguments('-X autotestdict=False', language: 'cython')
add_project_arguments('-X binding=True', language: 'cython')
add_project_arguments('-X c_api_binop_methods=True', language: 'cython')
add_project_arguments('-X cdivision=True', language: 'cython')
add_project_arguments('-X cpow=True', language: 'cython')
add_project_arguments('-X embedsignature=True', language: 'cython')
add_project_arguments('--embed-positions', language: 'cython')
add_project_arguments('-X fast_getattr=True', language: 'cython')
#add_project_arguments('-X language_level="3"', language : 'cython')
add_project_arguments('-X legacy_implicit_noexcept=True', language: 'cython')
add_project_arguments(
'-X preliminary_late_includes_cy28=True',
language: 'cython',
)
inc_cpython = include_directories('sage/cpython')
inc_rings = include_directories('sage/rings')
inc_rings_finite = include_directories('sage/rings/finite_rings')
inc_flint = include_directories('sage/libs/flint')
inc_gsl = include_directories('sage/libs/gsl')
inc_ntl = include_directories('sage/libs/ntl')
inc_arb = include_directories('sage/libs/arb')
inc_data_structures = include_directories('sage/data_structures')
inc_ext = include_directories('sage/ext')
inc_partn_ref2 = include_directories('sage/groups/perm_gps/partn_ref2')
inc_src = include_directories('.')
src = meson.current_source_dir()
# Submodules
subdir('sage')
subdir('doc')