-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeson.build
More file actions
304 lines (268 loc) · 11.1 KB
/
meson.build
File metadata and controls
304 lines (268 loc) · 11.1 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
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# Notice: if both static and dynamic libraries are present, the dynamic library will be used
# Forcing suffix lib instead of variants like lib64
project('gemc', 'cpp',
default_options : [
'default_library=static',
'default_both_libraries=static',
'libdir=lib'
],
version : run_command('ci/gemc_version.sh', check : true).stdout().strip(),
meson_version : '>= 1.10.1'
)
project_description = 'GEMC (GEant Monte-Carlo) is a program based on Geant4 to simulate the passage of particles through matter. '
# additional debug options useful for profiling
if get_option('buildtype') == 'debug'
add_project_arguments('-fno-omit-frame-pointer', language : 'cpp')
add_project_arguments('-fno-optimize-sibling-calls', language : 'cpp')
add_project_arguments('-O2', language : 'cpp')
endif
api_dir = join_paths(get_option('prefix'), 'api')
test_env = environment()
test_env.set('PYTHONDONTWRITEBYTECODE', '1')
test_env.prepend('PYTHONPATH', api_dir)
# init lists
############
LD = []
all_libs = []
all_includes = []
empty_dict = { 'na' : [''] }
lib_target_maps = {}
python_exe = import('python').find_installation('python3')
subdir('meson')
# Fill dictionary
#################
subdir('guts')
subdir('goptions')
subdir('glogging')
subdir('gbase')
subdir('gfactory')
subdir('textProgressBar')
subdir('gtouchable')
subdir('ghit')
subdir('gtranslationTable')
subdir('gdata')
subdir('gboard')
subdir('gdynamicDigitization')
subdir('gsystem') # uses api for testing
subdir('gstreamer')
subdir('eventDispenser')
subdir('gqtbuttonswidget')
subdir('g4display')
subdir('g4dialog')
subdir('g4system')
subdir('gparticle')
subdir('gphysics')
subdir('gsplash')
subdir('gsd') # TODO: example
subdir('gfields')
subdir('gdetector')
subdir('dbselect')
subdir('gtree')
subdir('gui')
subdir('actions') # TODO: example
subdir('utilities')
# compilation loop
foreach L : LD
this_lib_name = L['name'] # key name must be present
sources = L.get('sources', [''])
headers = L.get('headers', [''])
examples = L.get('examples', empty_dict)
geo_build = L.get('geo_build', empty_dict)
this_deps = L.get('dependencies', [])
this_internal_libs = L.get('internal_dependencies', [])
plugins = L.get('plugins', empty_dict)
additional_includes = L.get('additional_includes', [''])
moc_headers = L.get('moc_headers', [''])
moc_sources = []
qrc_sources = L.get('qrc_sources', [''])
qrc_examples_sources = L.get('qrc_examples_sources', [''])
qrc_compiled_sources = []
qrc_examples_compiled_sources = []
if not moc_headers.contains('')
moc_sources = qt6.compile_moc(headers : moc_headers,
dependencies : this_deps)
endif
if not sources.contains('')
if not qrc_sources.contains('')
qrc_compiled_sources += qt6.compile_resources(name : this_lib_name + '_qtresources', sources : qrc_sources)
endif
this_library = static_library(
this_lib_name,
sources + moc_sources + qrc_compiled_sources,
install : true,
dependencies : this_deps,
include_directories : all_includes + additional_includes
)
if not all_libs.contains(this_library)
all_libs += this_library
lib_target_maps += { this_lib_name : this_library }
endif
endif
# header files
if not headers.contains('')
install_headers(headers)
endif
this_library_link_with = []
# todo: this produces duplicates ROOT libraries
if not sources.contains('')
this_library_link_with += this_library
endif
foreach this_link_with : this_internal_libs
if lib_target_maps.has_key(this_link_with)
this_library_link_with += [lib_target_maps[this_link_with]]
endif
endforeach
if plugins != empty_dict
foreach name, sources : plugins
shared_library(
name,
sources[0],
install : sources[1],
dependencies : [this_deps, zlib_dep],
include_directories : all_includes + this_lib_name + additional_includes,
link_with : this_library_link_with,
name_suffix : 'gplugin',
name_prefix : '',
# Forces any static libraries that get built as part of the Meson project to be built with PIC
# so they can be linked into a shared module
override_options : ['b_staticpic=true']
)
endforeach
endif
# examples
if examples != empty_dict
# geometry, higher priority so it is run before the test
if geo_build != empty_dict
foreach name, geo_python_script : geo_build
examples_dir = get_option('prefix') + '/test/' + this_lib_name
source_subdir = this_lib_name + '/examples/'
install_subdir(source_subdir,
install_dir : examples_dir,
strip_directory : true,
follow_symlinks : true)
test(name,
python_exe,
args : [geo_python_script],
workdir : examples_dir,
is_parallel : false,
env : test_env,
priority : 20)
endforeach
endif
# example executables, lower priority so it's executed after build geometry
if not qrc_examples_sources.contains('')
qrc_examples_compiled_sources = qt6.compile_resources(name : this_lib_name + '_qtresources', sources : qrc_examples_sources)
endif
foreach name, sources_and_arguments : examples
# concatenate the items in sources_and_arguments[1] to a string
example_sources = sources_and_arguments[0] + qrc_examples_compiled_sources
arguments = sources_and_arguments[1]
exe = executable(
name,
example_sources,
install : true,
dependencies : this_deps,
include_directories : all_includes + this_lib_name + additional_includes,
link_with : this_library_link_with,
# Builds the executable as a PIE (position-independent executable).
override_options : ['b_pie=true']
)
test(name,
exe,
env : project_test_env,
args : arguments,
is_parallel : false,
priority : -20)
endforeach
endif
foreach include_dir : additional_includes
if not all_includes.contains(include_dir)
all_includes += include_dir
endif
endforeach
if not all_includes.contains(this_lib_name) and not (sources.contains('') and headers.contains(''))
all_includes += this_lib_name
endif
endforeach
# compile gemc
qrc_gemc_sources = qt6.compile_resources(sources : 'qtresources.qrc')
gemc_sources = ['gemc.cc', 'gemc_options.cc']
gemc = executable(
'gemc',
gemc_sources + qrc_gemc_sources + qrc_compiled_sources,
install : true,
dependencies : [yaml_cpp_dep, qt6_deps, clhep_deps, geant4_deps, ogl_deps, assimp_dep, zlib_dep],
include_directories : all_includes,
link_with : all_libs,
# Builds the executable as a PIE (position-independent executable).
override_options : ['b_pie=true']
)
# test gemc options. Adjust root to fit the geometry
examples_dir = get_option('prefix') + '/examples'
dbhost = ['-sql=' + examples_dir + '/gemc.db']
# TODO: change system with a custom with magnetic field, or use upcoming assign_field option
# If I put b2 here we need to add the diole definitions
gsystem = ['-gsystem="[{name: b2}]"']
general_gemc = ['-verbosity.gemc=2', '-debug.gemc=true', '-check_overlaps=2',
'-verbosity.gaction=2', '-debug.gaction=true',
'-verbosity.grunaction=2', '-debug.grunaction=true',
'-verbosity.grun=2', '-debug.grun=true',
'-verbosity.geventaction=2', '-debug.geventaction=true',
'-nthreads=4', '-n=8',
'-root="G4Box 25*cm 24*cm 40*cm G4_AIR"',
'-gmultipoles="[{name: dipole, pole_number: 2, strength: 2, rotaxis: Z, longitudinal: true}]"',
'-verbosity.eventdispenser=2', '-debug.eventdispenser=true']
root = ['-gstreamer="[{format: root, filename: out}]"']
ascii = ['-gstreamer="[{format: ascii, filename: out}]"']
gemc_test_sqlite = dbhost + gsystem + general_gemc
test_options = [
{ 'default' : [''] },
{ 'show_phys' : ['-showPhysics'] },
{ 'phys_verbose' : ['-verbosity.gphysics=2', '-debug.gphysics=true'] },
{ 'gui_verbose' : ['-verbosity.dbselect=2', '-debug.dbselect=true',
'-verbosity.gsplash=2', '-debug.gsplash=true'] },
{ 'detector_verbose' : ['-verbosity.gdetector=2', '-debug.gdetector=true',
'-verbosity.gsystem=2', '-debug.gsystem=true',
'-verbosity.g4system=2', '-debug.g4system=true'] },
{ 'gdigitization_verbose' : ['-verbosity.gdigitization=2', '-debug.gdigitization=true',
'-verbosity.plugins=2', '-debug.plugins=true',
'-verbosity.gtranslationtable=2', '-debug.gtranslationtable=true',
'-verbosity.gsd=2', '-debug.gsd=true',
'-verbosity.gdetector=2', '-debug.gdetector=true',
'-verbosity.gtouchable=2', '-debug.gtouchable=true'] },
{ 'gstreamer_verbose' : ['-verbosity.digitized_data=2', '-debug.digitized_data=true',
'-verbosity.gstreamer=2', '-debug.gstreamer=true',
'-verbosity.true_data=2', '-debug.true_data=true',
'-gstreamer="[{format: root, filename: out}, {format: ascii, filename: out} ]"'] },
{ 'gfield_verbose' : ['-verbosity.gfield=1', '-debug.gfield=true',
'-gmultipoles="[{name: dipole, pole_number: 2, strength: 2, rotaxis: Z, longitudinal: true}]"',
'-gparticle="[{name: e-, p: 2300, theta: 23.0}]"'] }
]
foreach opt_dict : test_options
foreach key, value : opt_dict # each dict has exactly one entry
test_name = 'gemc_' + key # => gemc_default, gemc_show_pys
test_arguments = value
test(
test_name,
gemc,
args : test_arguments + gemc_test_sqlite,
# suite : 'gemc',
is_parallel : false,
timeout : 60, # adjust as needed
priority : -20
)
endforeach
endforeach
subdir('api')
subdir('examples')
post_install = run_command('echo', 'Installation completed!', check : true)
# generate pkg-config file
# needs testing - add libraries?
#pkg = import('pkgconfig')
#pkg.generate(
# name : meson.project_name(),
# description : project_description,
# requires : ['yaml-cpp', 'qt6', 'clhep', 'geant4'], # pkg-config dependencies only
# version : meson.project_version(),
# # libraries : all_libs
#)