-
Notifications
You must be signed in to change notification settings - Fork 149
/
meson.build
212 lines (185 loc) · 5.87 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# This file is part of xtb.
#
# Copyright (C) 2019-2020 Sebastian Ehlert
#
# xtb is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# xtb is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with xtb. If not, see <https://www.gnu.org/licenses/>.
# extended tight binding program package
project(
'xtb',
'fortran', 'c',
version: '6.7.1',
license: 'LGPL3-3.0-or-later',
meson_version: '>=0.62.0',
default_options: [
'buildtype=debugoptimized',
'default_library=both',
'optimization=2',
'c_std=c11',
],
)
install = not meson.is_subproject()
install_modules = install and get_option('install_modules')
commit = get_option('build_name')
git = find_program('git', required: false)
if git.found()
git_commit = run_command(git, 'show', '-s', '--format=%h')
if git_commit.returncode() == 0
commit = git_commit.stdout().strip()
endif
endif
# We rely on the existence of Python since meson will need a Python interpreter to run,
# this way we have a cross-platform way to obtain relevant data for our build.
pymod = import('python')
python = pymod.find_installation('python3', required: false)
if not python.found()
python = find_program('python3', 'python')
endif
# build a configuration data containing all the important data to propagate
# it to the automatically generated files
config = configuration_data({
'name': meson.project_name(),
'description': 'Semiempirical Extended Tight-Binding Program Package',
'version': meson.project_version(),
'commit': commit,
'date': run_command(python, '-c', 'import datetime; print(datetime.date.today().strftime("%Y-%m-%d"))').stdout().strip(),
'author': run_command(python, '-c', 'import getpass; print(getpass.getuser())').stdout().strip(),
'origin': run_command(python, '-c', 'import socket; print(socket.gethostname())').stdout().strip(),
'prefix': get_option('prefix'),
'mandir': get_option('mandir'),
'bindir': get_option('bindir'),
'libdir': get_option('libdir'),
'includedir': get_option('includedir'),
'datadir': get_option('datadir')/meson.project_name(),
})
configure_file(
input: files('assets/templates/version.f90'),
output: 'xtb_version.fh',
configuration : config,
)
## ========================================== ##
## Configuration and dependencies
## ========================================== ##
lib_deps = []
subdir('meson')
## ========================================== ##
## Sources
## ========================================== ##
srcs = []
prog = []
main = []
subdir('src')
srcs += 'symmetry/symmetry.f90'
srcs += 'symmetry/symmetry_i.c'
if get_option('nvtx')
srcs += 'src/nvtx.f90'
endif
xtb_inc = meson.current_source_dir() / 'include'
incdir = include_directories('include')
# Build target
xtb_lib = library(
meson.project_name(),
sources: srcs,
version: meson.project_version(),
dependencies: lib_deps,
include_directories: incdir,
install: install,
fortran_args: [
'-DWITH_TBLITE=@0@'.format(tblite_dep.found() ? 1 : 0),
'-DWITH_CPCMX=@0@'.format(cpx_dep.found() ? 1 : 0),
],
link_language: 'fortran',
)
xtb_dep = declare_dependency(
link_with: xtb_lib,
include_directories: [incdir, xtb_lib.private_dir_include()],
dependencies: lib_deps,
version: meson.project_version(),
)
xtb_common = get_option('default_library') == 'both' ? xtb_lib.get_static_lib() : xtb_lib
xtb_dep_static = declare_dependency(
link_with: xtb_common,
include_directories: [incdir, xtb_lib.private_dir_include()],
dependencies: lib_deps,
version: meson.project_version(),
)
xtb_exe = executable(
meson.project_name(),
sources: prog,
dependencies: xtb_dep_static,
link_language: 'fortran',
install: install,
fortran_args: [
'-DWITH_TBLITE=@0@'.format(tblite_dep.found() ? 1 : 0),
'-DWITH_CPCMX=@0@'.format(cpx_dep.found() ? 1 : 0),
],
)
xtb_header = files('include/xtb.h')
## ========================================== ##
## INSTALL
## ========================================== ##
if install
install_headers(xtb_header)
endif
asciidoc = find_program('asciidoctor', required: false)
if asciidoc.found()
xtb_man = []
xtb_man += configure_file(
command: [asciidoc, '-b', 'manpage', '@INPUT@', '-o', '@OUTPUT@'],
input: files('man/xtb.1.adoc'),
output: '@BASENAME@',
)
xtb_man += configure_file(
command: [asciidoc, '-b', 'manpage', '@INPUT@', '-o', '@OUTPUT@'],
input: files('man/xcontrol.7.adoc'),
output: '@BASENAME@',
)
if install
install_man(xtb_man)
endif
endif
xtb_parameter_files = [
'param_gfn0-xtb.txt',
'param_gfn2-xtb.txt',
'param_gfn1-xtb.txt',
'param_gfn1-si-xtb.txt',
'param_ipea-xtb.txt',
'.param_gfnff.xtb',
]
if install
install_data(xtb_parameter_files)
endif
if install_modules
xtb_objs = []
foreach file: srcs
xtb_objs += '@[email protected]'.format('_'.join(file.split('/')))
endforeach
install_subdir(meson.current_build_dir()/'@0@@sta'.format(meson.project_name()),
install_dir: 'include',
strip_directory: true,
exclude_files: xtb_objs)
endif
# additional misc. files
if install
subdir('assets')
endif
## ========================================== ##
## TESTSUITE
## ========================================== ##
# make sure the correct library is loaded
xtbenv = environment()
xtbenv.prepend('LD_LIBRARY_PATH', meson.current_build_dir())
xtbenv.prepend('PYTHONPATH', meson.current_source_dir() / 'python')
xtbenv.set('XTBPATH', meson.current_source_dir())
# all tests are defined in a separate meson.build
subdir('test')