Repository navigation
Expand file tree
/
Copy pathmeson.build
More file actions
94 lines (86 loc) · 3.42 KB
/
Copy pathmeson.build
File metadata and controls
94 lines (86 loc) · 3.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
# https://mesonbuild.com/
project(
'extxyz', # Project name
'c',
# Use 'python' which works cross-platform inside cibuildwheel
version: run_command('python', 'discover_version.py', check: true).stdout().strip(), # Project version
)
# https://mesonbuild.com/Python-module.html
pymod = import('python')
# Don't specify 'python3' - let Meson find the Python used to run itself
python = pymod.find_installation(
required: true,
pure: false
)
host_system = host_machine.system()
cc = meson.get_compiler('c')
# numpy headers for the C-API fast read path in the _extxyz extension. Resolved
# non-fatally: a standalone C/Fortran/Julia build without numpy still configures
# (the extension then falls back to the ctypes-only marshalling path).
np_cmd = run_command(python, '-c',
'import numpy; print(numpy.get_include())', check: false)
have_numpy = np_cmd.returncode() == 0
if have_numpy
# Pass as a -I compile arg rather than include_directories(): numpy's include
# path is absolute and may sit inside the source tree (e.g. an in-repo .venv),
# which include_directories() rejects. -I works regardless of location.
numpy_inc_arg = '-I' + np_cmd.stdout().strip()
message('numpy headers found: building _extxyz with the C-API fast read path')
else
message('numpy headers not found: _extxyz will use the ctypes read path only')
endif
# Determine MSVC runtime library (for PCRE2 library name)
vs_crt = 'release'
vs_crt_opt = get_option('b_vscrt')
if vs_crt_opt in ['mdd', 'mtd']
vs_crt = 'debug'
elif vs_crt_opt == 'from_buildtype'
if get_option('buildtype') == 'debug'
vs_crt = 'debug'
endif
endif
# adapted from https://gitlab.gnome.org/GNOME/glib/-/blob/cd9a5c173a154e326a3ebaa28cfe41a7444625c5/meson.build#L2020-L2052
pcre2 = dependency('libpcre2-8', version: '>= 10.23', required : false)
if not pcre2.found()
if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
# MSVC: Search for the PCRE2 library by the configuration, which corresponds
# to the output of CMake builds of PCRE2. Note that debugoptimized
# is really a Release build with .PDB files.
if vs_crt == 'debug'
pcre2 = cc.find_library('pcre2d-8', required : false)
else
pcre2 = cc.find_library('pcre2-8', required : false)
endif
elif host_system == 'windows'
# MinGW/GCC on Windows: Try to find the library directly
pcre2 = cc.find_library('pcre2-8', required : false)
endif
endif
# Try again with the fallback
if not pcre2.found()
pcre2 = dependency('libpcre2-8', required : true, fallback : ['pcre2', 'libpcre2_8'])
use_pcre2_static_flag = true
elif host_system == 'windows'
pcre2_static = cc.links('''#define PCRE2_STATIC
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
int main() {
void *p = NULL;
pcre2_code_free(p);
return 0;
}''',
dependencies: pcre2,
name : 'Windows system PCRE2 is a static build')
use_pcre2_static_flag = pcre2_static
else
use_pcre2_static_flag = false
endif
quip_lib_dir = get_option('quip_lib_dir')
quip_mod_dir = get_option('quip_mod_dir')
build_fextxyz = quip_lib_dir != '' and quip_mod_dir != ''
if build_fextxyz
add_languages('fortran', required: true, native: false)
endif
subdir('libcleri')
subdir('libextxyz')
subdir('python/extxyz')