-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmeson.build
119 lines (105 loc) · 3.25 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
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
# Zofu Meson build script
project('zofu', ['fortran'], version: '1.1.1')
if meson.get_compiler('fortran').get_id() == 'gcc'
f_args = ['-Wno-maybe-uninitialized']
else
f_args = []
endif
if get_option('mpi_wrapper_compiler')
deps = []
mpi_found = true
else
mpi = dependency('mpi', language: 'fortran', required: false)
deps = mpi
mpi_found = mpi.found()
endif
prefix = get_option('prefix')
libdir = get_option('libdir')
src_dir = join_paths(meson.current_source_dir(), 'src')
zofu_modules = ['zofu_kinds.F90', 'zofu.F90',
'zofu_str_utils.F90', 'zofu_scan.F90']
if mpi_found
zofu_modules += ['zofu_mpi.F90']
endif
zofu_sources = []
foreach m: zofu_modules
zofu_sources += [join_paths(src_dir, m)]
endforeach
zofu = shared_library('zofu',
zofu_sources,
fortran_args: f_args,
dependencies: deps,
install: true)
zofu_dep = declare_dependency(link_with : zofu)
driver_exe = executable(
'zofu-driver',
join_paths(src_dir, 'zofu_driver.F90'),
fortran_args: f_args,
link_with: zofu,
install: true,
install_rpath: join_paths(prefix, libdir))
includedir = get_option('includedir')
if includedir != ''
module_install_dir = join_paths(prefix, includedir)
zofu_objs = []
foreach m: zofu_modules
zofu_objs += [m + '.o']
endforeach
# NB this is a temporary measure until Meson gets specific
# functionality for installing Fortran modules:
if meson.version().version_compare('<0.55')
mod_dir = 'zofu@sha'
else
mod_dir = zofu.full_path().split('/').get(-1) + '.p'
endif
mod_path = join_paths(meson.current_build_dir(), mod_dir)
install_subdir(mod_path,
install_dir: module_install_dir,
strip_directory: true,
exclude_files: zofu_objs)
pkg = import('pkgconfig')
pkg.generate(zofu,
description: 'Zofu is Object-oriented Fortran Unit-testing')
endif
# Zofu tests:
test_modules = ['test_str_utils',
'test_logical_asserts',
'test_integer_asserts',
'test_real_asserts',
'test_double_asserts',
'test_complex_asserts',
'test_string_asserts']
test_src_dir = join_paths(meson.current_source_dir(), 'test')
foreach test_module: test_modules
test_exe = executable(
test_module,
[join_paths(test_src_dir, test_module + '.F90'),
join_paths(test_src_dir, 'check.F90')],
fortran_args: f_args,
link_with: zofu)
test(test_module, test_exe)
endforeach
if mpi_found
mpi_test_modules = ['test_mpi']
foreach test_module: mpi_test_modules
test_exe = executable(
test_module,
[join_paths(test_src_dir, test_module + '.F90'),
join_paths(test_src_dir, 'check_mpi.F90')],
fortran_args: f_args,
link_with: zofu,
dependencies: deps)
test(test_module, test_exe, is_parallel: false)
endforeach
endif
# Zofu scan tests:
test_module = 'test_zofu_scan'
test_env = environment()
test_env.set('ZOFU_TEST_DATA_PATH',
join_paths(meson.current_source_dir(), 'test', 'data', ''))
test_exe = executable(
test_module,
join_paths(test_src_dir, test_module + '.F90'),
fortran_args: f_args,
link_with: zofu)
test(test_module, test_exe, env: test_env)