Repository navigation
Expand file tree
/
Copy pathmeson.build
More file actions
116 lines (100 loc) · 2.42 KB
/
Copy pathmeson.build
File metadata and controls
116 lines (100 loc) · 2.42 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
project(
'mkl-service',
['c', 'cython'],
version: run_command(
find_program('python3', 'python'),
['-c', 'exec(open("mkl/_version.py").read()); print(__version__)'],
check: true
).stdout().strip(),
meson_version: '>=1.8.3',
default_options: [
'c_std=c11',
'buildtype=release',
]
)
py = import('python').find_installation(pure: false)
c_args = ['-DNDEBUG']
cmake_mkl_interface = 'lp64'
if get_option('ilp64')
c_args += '-DMKL_ILP64'
cmake_mkl_interface = 'ilp64'
endif
thread_dep = dependency('threads')
cc = meson.get_compiler('c')
atomics_args = []
if cc.get_id() == 'msvc'
atomics_args += '/experimental:c11atomics'
endif
# checked to fail early if missing header
if not cc.has_header('stdatomic.h', args: atomics_args)
error(
'mkl-service requires a C compiler supporting C11 atomics',
'(i.e., for Windows, Visual Studio 2022 17.5 or newer).'
)
endif
mkl_dep = dependency('MKL', method: 'cmake',
modules: ['MKL::MKL'],
cmake_args: [
'-DMKL_ARCH=intel64',
'-DMKL_LINK=sdl',
'-DMKL_INTERFACE=' + cmake_mkl_interface,
],
required: true
)
rpath_link_args = []
if host_machine.system() != 'windows'
if host_machine.system() == 'darwin'
origin = '@loader_path'
else
origin = '$ORIGIN'
endif
rpath_link_args = [
'-Wl,-rpath,' + origin / '../..',
'-Wl,-rpath,' + origin / '../../..',
]
endif
# C extension
py.extension_module(
'_mklinit',
sources: ['mkl/_mklinitmodule.c'],
dependencies: [mkl_dep, thread_dep],
c_args: c_args + ['-DUSING_MKL_RT'],
link_args: rpath_link_args,
install: true,
subdir: 'mkl'
)
# Cython extensions
py.extension_module(
'_py_mkl_service',
sources: ['mkl/_py_mkl_service.pyx'],
dependencies: [mkl_dep],
c_args: c_args,
link_args: rpath_link_args,
install: true,
subdir: 'mkl'
)
py.extension_module(
'_mkl_memory',
sources: ['mkl/_mkl_memory.pyx'],
dependencies: [mkl_dep],
c_args: c_args + atomics_args,
link_args: rpath_link_args,
install: true,
subdir: 'mkl'
)
# Python sources
py.install_sources(
[
'mkl/__init__.py',
'mkl/_init_helper.py',
'mkl/_version.py',
],
subdir: 'mkl'
)
py.install_sources(
[
'mkl/tests/test_mkl_memory.py',
'mkl/tests/test_mkl_service.py',
],
subdir: 'mkl/tests'
)