-
Notifications
You must be signed in to change notification settings - Fork 8
/
meson.build
78 lines (69 loc) · 2.56 KB
/
meson.build
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
# Much of this is from SciPy
project(
'pyhams',
'c',
# unnecessary metadata commented out until Meson supports PEP517 and installation with pip
license: 'Apache',
#meson_version: '>= 0.60',
default_options: [
'buildtype=debugoptimized',
'b_ndebug=if-release',
'c_std=c11',
],
)
cc = meson.get_compiler('c')
add_languages('fortran', native: false)
fc = meson.get_compiler('fortran')
message(fc.get_id())
is_windows = host_machine.system() == 'windows'
is_mac = host_machine.system() == 'darwin'
# We need -lm for all C code (assuming it uses math functions, which is safe to
# assume for SciPy). For C++ it isn't needed, because libstdc++/libc++ is
# guaranteed to depend on it. For Fortran code, Meson already adds `-lm`.
m_dep = cc.find_library('m', required : false)
if m_dep.found()
add_project_link_arguments('-lm', language : 'c')
endif
# Adding at project level causes many spurious -lgfortran flags.
if fc.has_argument('-Wno-conversion')
add_project_arguments('-Wno-conversion', language: 'fortran')
endif
_fflags = []
if fc.get_id() in ['intel', 'intel-llvm']
_fflags = fc.get_supported_arguments('-qmkl')
_fflags += fc.get_supported_arguments('-fp-model=strict')
minus0_arg = ['-assume', 'minus0']
if fc.has_multi_arguments(minus0_arg)
_fflags += minus0_arg
endif
elif fc.get_id() in ['intel-cl', 'intel-llvm-cl']
# Intel Fortran on Windows does things differently, so deal with that
# (also specify dynamic linking and the right name mangling)
_fflags = fc.get_supported_arguments('/qmkl')
_fflags += fc.get_supported_arguments(
'/fp:strict', '/MD', '/names:lowercase', '/assume:underscore',
'/assume:minus0'
)
else
_fflags = fc.get_supported_arguments('-fdec-math')
_fflags += fc.get_supported_arguments('-fno-align-commons')
endif
add_project_arguments(_fflags, language: 'fortran')
#omp = dependency('OpenMP', required: false)
if fc.get_id() in ['intel', 'intel-llvm']
omp = declare_dependency(link_args: '-qopenmp')
elif fc.get_id() in ['intel-cl', 'intel-llvm-cl']
omp = declare_dependency(link_args: '/qopenmp')
elif is_mac
omp = declare_dependency(link_args: ['-Xpreprocessor', '-Xclang', '-fopenmp'])
else
omp = declare_dependency(link_args: '-fopenmp')
endif
# https://mesonbuild.com/Python-module.html
# Here we differentiate from the python used by meson, py3_command, and that python target, py3_target. This is useful
# when cross compiling like on conda-forge
py3 = import('python').find_installation(pure: false)
py3_dep = py3.dependency()
message(py3.path())
message(py3.get_install_dir())
subdir('pyhams')