-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmeson.build
91 lines (77 loc) · 2.57 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
79
80
81
82
83
84
85
86
87
88
89
90
91
project(
'pymsis',
'c',
# Note that the git commit hash cannot be added dynamically here
version: run_command('python', '-m', 'setuptools_scm', check: true).stdout().strip(),
license: 'MIT',
meson_version: '>=1.2.99',
default_options: [
'fortran_std=legacy',
],
)
cc = meson.get_compiler('c')
# TODO: the below -Wno flags are all needed to silence warnings in
# f2py-generated code. This should be fixed in f2py itself.
_global_c_args = cc.get_supported_arguments(
'-Wno-unused-but-set-variable',
'-Wno-unused-function',
'-Wno-conversion',
'-Wno-misleading-indentation',
'-Wno-incompatible-pointer-types',
)
add_project_arguments(_global_c_args, language : 'c')
# Adding at project level causes many spurious -lgfortran flags.
add_languages('fortran', native: false)
ff = meson.get_compiler('fortran')
if ff.has_argument('-Wno-conversion')
add_project_arguments('-Wno-conversion', language: 'fortran')
endif
# Default to optimization level 1
# Some CI jobs fail with higher levels of optimization, so restrict this by default.
add_project_arguments('-O1', language: 'fortran')
is_windows = host_machine.system() == 'windows'
# Platform detection
is_mingw = is_windows and cc.get_id() == 'gcc'
if is_windows
# Need static libraries to get libgfortran
gcc_link_args = ['-static']
if is_mingw
add_project_link_arguments(gcc_link_args, language: ['c'])
endif
if meson.get_compiler('fortran').get_id() == 'gcc'
add_project_link_arguments(gcc_link_args, language: ['fortran'])
endif
endif
generate_f2pymod = files('tools/generate_f2pymod.py')
# https://mesonbuild.com/Python-module.html
py_mod = import('python')
py3 = py_mod.find_installation(pure: false)
py3_dep = py3.dependency()
incdir_numpy = run_command(py3,
['-c', 'import os; os.chdir(".."); import numpy; print(numpy.get_include())'],
check : true
).stdout().strip()
inc_np = include_directories(incdir_numpy)
incdir_f2py = incdir_numpy / '..' / '..' / 'f2py' / 'src'
inc_f2py = include_directories(incdir_f2py)
fortranobject_c = incdir_f2py / 'fortranobject.c'
# Share this object across multiple modules.
fortranobject_lib = static_library('_fortranobject',
fortranobject_c,
dependencies: py3_dep,
include_directories: [inc_np, inc_f2py],
)
fortranobject_dep = declare_dependency(
link_with: fortranobject_lib,
include_directories: [inc_np, inc_f2py],
)
generate_f2pymod = files('tools/generate_f2pymod.py')
# Get the external sources
run_command(py3,
files('tools/download_source.py'),
check : true
)
# Must build the src extensions first
subdir('src')
subdir('pymsis')
subdir('tests')