aboutsummaryrefslogtreecommitdiff
path: root/meson.build
blob: 77aa5ed9beb7cecb39c03ff436d2916bb7a07e7c (plain)
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
# Meson file for CrystFEL
project('crystfel', 'c',
        version : '0.8.0',
        license : 'GPL3+',
        default_options : ['buildtype=debugoptimized'])

add_project_arguments('-DHAVE_CONFIG_H', language : 'c')

# FIXME: Possibly Git SHA1
conf_data = configuration_data()
conf_data.set('CRYSTFEL_VERSION',  meson.project_version())

# Mandatory dependencies
cc = meson.get_compiler('c')
mdep = cc.find_library('m', required : true)
gsldep = dependency('gsl', required : true)
zlibdep = dependency('zlib', required : true)
pthreaddep = dependency('threads', required : true)

# HDF5 >= 1.8.21 and >= 1.10.2 has a pkg-config file:
hdf5dep = dependency('hdf5', language : 'c', required : false)

# Otherwise, try finding it ourselves:
if not hdf5dep.found()
  hdf5dep = cc.find_library('hdf5', required : false)
endif

if not hdf5dep.found()
  error('Couldn\'t find HDF5')
endif

# "Optional" dependencies
fftwdep = dependency('fftw3', required : false)
if fftwdep.found()
  conf_data.set10('HAVE_FFTW', 1)
endif

tiffdep = dependency('libtiff-4', required : false)
if tiffdep.found()
  conf_data.set10('HAVE_TIFF', 1)
endif

gtkdep = dependency('gtk+-3.0', required : false)
if not gtkdep.found()
  gtkdep = dependency('gtk+-2.0', required : false)
else
  add_project_arguments('-Wno-deprecated-declarations', language : 'c')
endif

if gtkdep.found()
  conf_data.set10('HAVE_GTK', 1)
endif

gdkdep = dependency('gdk-3.0', required : false)
if not gdkdep.found()
  gdkdep = dependency('gdk-2.0', required : false)
endif
if gdkdep.found()
  conf_data.set10('HAVE_GDK', 1)
endif

gdkpixbufdep = dependency('gdk-pixbuf-2.0', required : false)
if gdkpixbufdep.found()
  conf_data.set10('HAVE_GDKPIXBUF', 1)
endif

cairodep = dependency('cairo', required : false)
if cairodep.found()
  conf_data.set10('HAVE_CAIRO', 1)
endif

opencldep = dependency('OpenCL', required : false)
if opencldep.found()
  conf_data.set10('HAVE_OPENCL', 1)
endif
if cc.has_header('CL/cl.h')
  conf_data.set10('HAVE_CL_CL_H', 1)
endif

zmqdep = dependency('libzmq', required : false)
if zmqdep.found()
  conf_data.set10('HAVE_ZMQ', 1)
endif

msgpackdep = dependency('msgpack', required : false)
if msgpackdep.found()
  conf_data.set10('HAVE_MSGPACK', 1)
endif

if cc.has_function('clock_gettime', prefix : '#include <time.h>')
  conf_data.set10('HAVE_CLOCK_GETTIME', 1)
endif

# ************************ libcrystfel (subdir) ************************

subdir('libcrystfel')

# ************************ The programs ************************

configure_file(input : 'config.h.in',
               output : 'config.h',
               configuration : conf_data)
conf_inc = include_directories('.')

# cell_tool
executable('cell_tool',
           ['src/cell_tool.c'],
           dependencies : [mdep, libcrystfeldep],
           install : true)

# partial_sim
# FIXME: restore
#executable('partial_sim',
#           ['src/partial_sim.c'],
#           dependencies : [mdep, libcrystfeldep, gsldep, pthreaddep],
#           install : true)

# process_hkl
executable('process_hkl',
           ['src/process_hkl.c'],
           dependencies : [mdep, libcrystfeldep],
           install : true)

# list_events
executable('list_events',
           ['src/list_events.c'],
           dependencies : [mdep, libcrystfeldep],
           install : true)

# get_hkl
executable('get_hkl',
           ['src/get_hkl.c'],
           dependencies : [mdep, libcrystfeldep, gsldep],
           install : true)

# compare_hkl
executable('compare_hkl',
           ['src/compare_hkl.c'],
           dependencies : [mdep, libcrystfeldep, gsldep],
           install : true)

# check_hkl
executable('check_hkl',
           ['src/check_hkl.c'],
           dependencies : [mdep, libcrystfeldep, gsldep],
           install : true)

# partialator
executable('partialator',
           ['src/partialator.c',
            'src/post-refinement.c',
            'src/merge.c',
            'src/rejection.c',
            'src/scaling.c'],
           dependencies : [mdep, libcrystfeldep, gsldep, pthreaddep],
           install : true)

# ambigator
executable('ambigator',
           ['src/ambigator.c'],
           dependencies : [mdep, libcrystfeldep, gsldep, hdf5dep],
           install : true)

# whirligig
executable('whirligig',
           ['src/whirligig.c'],
           dependencies : [mdep, libcrystfeldep],
           install : true)

# indexamajig
indexamajig_sources = ['src/indexamajig.c', 'src/im-sandbox.c',
                       'src/process_image.c', 'src/time-accounts.c']
if zmqdep.found() and msgpackdep.found()
  indexamajig_sources += ['src/im-zmq.c']
endif

executable('indexamajig', indexamajig_sources,
           dependencies : [mdep, libcrystfeldep, gsldep, pthreaddep, zmqdep,
                           msgpackdep],
           install : true)

# make_pixelmap
executable('make_pixelmap',
           ['src/make_pixelmap.c'],
           dependencies : [mdep, libcrystfeldep, hdf5dep],
           install : true)

# geoptimiser
# FIXME: restore
#executable('geoptimiser',
#           ['src/geoptimiser.c', 'src/hdfsee-render.c'],
#           dependencies : [mdep, libcrystfeldep, gsldep, gdkpixbufdep, gdkdep,
#                           tiffdep],
#           install : true)

# CrystFEL GUI
if gtkdep.found()
  executable('crystfel',
             ['src/crystfel_gui.c',
              'src/crystfelimageview.c',
              'src/gui_peaksearch.c',
              'src/gui_index.c',
              'src/gui_backend_local.c',
              'src/gui_project.c'],
             dependencies : [mdep, libcrystfeldep, gtkdep, gsldep],
             install : true)
endif

# render_hkl
executable('render_hkl',
           ['src/render_hkl.c'],
           dependencies : [mdep, libcrystfeldep, cairodep, gsldep],
           install : true)

# cell_explorer
if gtkdep.found()
  executable('cell_explorer',
             ['src/cell_explorer.c', 'src/multihistogram.c'],
             dependencies : [mdep, libcrystfeldep, gtkdep, gsldep],
             install : true)
endif

# pattern_sim
# FIXME: restore
#pattern_sim_sources = ['src/pattern_sim.c', 'src/diffraction.c']
#if opencldep.found()
#  pattern_sim_sources += ['src/diffraction-gpu.c', 'src/cl-utils.c']
#endif
#executable('pattern_sim', pattern_sim_sources,
#           dependencies : [mdep, libcrystfeldep, gsldep, hdf5dep, opencldep],
#           install : true)

# FIXME: Install manual pages

# FIXME: Tests