]> git.sesse.net Git - nageru/blob - nageru/meson.build
Move everything into a separate futatabi/ subdir, for the upcoming merge with Futatabi.
[nageru] / nageru / meson.build
1 qt5 = import('qt5')
2 protoc = find_program('protoc')
3 cxx = meson.get_compiler('cpp')
4
5 # Use lld if we can; it links a lot faster than ld.bfd or gold.
6 nageru_link_args = []
7 code = '''#include <stdio.h>
8 int main() { printf("Hello, world!\n"); return 0; }
9 '''
10 if cxx.links(code, args: '-fuse-ld=lld', name: 'check for LLD')
11         nageru_link_args += '-fuse-ld=lld'
12 endif
13
14 embedded_bmusb = get_option('embedded_bmusb')
15
16 alsadep = dependency('alsa')
17 bmusbdep = dependency('bmusb', required: not embedded_bmusb)
18 dldep = cxx.find_library('dl')
19 epoxydep = dependency('epoxy')
20 libavcodecdep = dependency('libavcodec')
21 libavformatdep = dependency('libavformat')
22 libavresampledep = dependency('libavresample')
23 libavutildep = dependency('libavutil')
24 libjpegdep = dependency('libjpeg')
25 libmicrohttpddep = dependency('libmicrohttpd')
26 libswscaledep = dependency('libswscale')
27 libusbdep = dependency('libusb-1.0')
28 luajitdep = dependency('luajit')
29 movitdep = dependency('movit')
30 protobufdep = dependency('protobuf')
31 qcustomplotdep = cxx.find_library('qcustomplot')
32 qt5deps = dependency('qt5', modules: ['Core', 'Gui', 'Widgets', 'OpenGLExtensions', 'OpenGL', 'PrintSupport'])
33 threaddep = dependency('threads')
34 vadrmdep = dependency('libva-drm')
35 vax11dep = dependency('libva-x11')
36 x11dep = dependency('x11')
37 x264dep = dependency('x264')
38 zitaresamplerdep = cxx.find_library('zita-resampler')
39
40 srcs = []
41 nageru_deps = [qt5deps, libjpegdep, movitdep, libmicrohttpddep, protobufdep,
42         vax11dep, vadrmdep, x11dep, libavformatdep, libavresampledep, libavcodecdep, libavutildep,
43         libswscaledep, libusbdep, luajitdep, dldep, x264dep, alsadep, zitaresamplerdep,
44         qcustomplotdep, threaddep]
45 nageru_include_dirs = []
46 nageru_link_with = []
47 nageru_build_rpath = ''
48 nageru_install_rpath = ''
49
50 kaeru_link_with = []
51 kaeru_extra_deps = []
52
53 # DeckLink has these issues, and we include it from various places.
54 if cxx.has_argument('-Wno-non-virtual-dtor')
55         add_project_arguments('-Wno-non-virtual-dtor', language: 'cpp')
56 endif
57
58 # FFmpeg has a lot of deprecated APIs whose replacements are not available
59 # in Debian stable, so we suppress these warnings.
60 if cxx.has_argument('-Wno-deprecated-declarations')
61         add_project_arguments('-Wno-deprecated-declarations', language: 'cpp')
62 endif
63
64 # Add the right MOVIT_SHADER_DIR definition.
65 r = run_command('pkg-config', '--variable=shaderdir', 'movit')
66 if r.returncode() != 0
67         error('Movit pkg-config installation is broken.')
68 endif
69 add_project_arguments('-DMOVIT_SHADER_DIR="' + r.stdout().strip() + '"', language: 'cpp')
70
71 # CEF.
72 exe_dir = join_paths(get_option('prefix'), 'lib/nageru')
73 cef_dir = get_option('cef_dir')
74 cef_build_type = get_option('cef_build_type')
75 have_cef = (cef_dir != '')
76 if have_cef
77         add_project_arguments('-DHAVE_CEF=1', language: 'cpp')
78
79         system_cef = (cef_build_type == 'system')
80         if system_cef
81                 cef_lib_dir = cef_dir
82                 cef_resource_dir = '/usr/share/cef/Resources'
83         else
84                 cef_lib_dir = join_paths(cef_dir, cef_build_type)
85                 cef_resource_dir = join_paths(cef_dir, 'Resources')
86
87                 nageru_include_dirs += include_directories(cef_dir)
88                 nageru_include_dirs += include_directories(join_paths(cef_dir, 'include'))
89                 nageru_build_rpath = cef_lib_dir
90                 nageru_install_rpath = '$ORIGIN/'
91         endif
92
93         cefdep = cxx.find_library('cef')
94         nageru_deps += cefdep
95
96         # CEF wrapper library; not built as part of the CEF binary distribution,
97         # but should be if CEF is installed as a system library.
98         if system_cef
99                 cefdlldep = cxx.find_library('cef_dll_wrapper')
100                 nageru_deps += cefdlldep
101         else
102                 cmake = find_program('cmake')
103                 cef_compile_script = find_program('scripts/compile_cef_dll_wrapper.sh')
104
105                 cef_dll_target = custom_target('libcef_dll_wrapper',
106                         input: join_paths(cef_dir, 'libcef_dll/CMakeLists.txt'),
107                         output: ['libcef_dll_wrapper.a', 'cef-stamp'],
108                         command: [cef_compile_script, '@BUILD_DIR@', cef_dir, cmake, '@OUTPUT@'])
109
110                 # Putting the .a in sources seemingly hits a bug where the .a files get sorted
111                 # in the wrong order. This is a workaround; see
112                 # https://github.com/mesonbuild/meson/issues/3613#issuecomment-408276296 .
113                 cefdlldep = declare_dependency(sources: cef_dll_target[1], link_args: cef_dll_target.full_path())
114                 nageru_deps += cefdlldep
115         endif
116
117         cef_libs = ['libEGL.so', 'libGLESv2.so', 'natives_blob.bin', 'snapshot_blob.bin', 'v8_context_snapshot.bin']
118         cef_resources = ['cef.pak', 'cef_100_percent.pak', 'cef_200_percent.pak', 'cef_extensions.pak', 'devtools_resources.pak']
119         if not get_option('cef_no_icudtl')
120                 cef_resources += ['icudtl.dat']
121         endif
122         if cef_build_type != 'system'
123                 cef_libs += ['libcef.so']
124         endif
125
126         # Symlink the files into the build directory, so that running nageru without ninja install works.
127         run_command('mkdir', join_paths(meson.current_build_dir(), 'locales/'))
128         foreach file : cef_libs
129                 run_command('ln', '-s', join_paths(cef_lib_dir, file), meson.current_build_dir())
130                 install_data(join_paths(cef_lib_dir, file), install_dir: exe_dir)
131         endforeach
132         foreach file : cef_resources
133                 run_command('ln', '-s', join_paths(cef_resource_dir, file), meson.current_build_dir())
134                 install_data(join_paths(cef_resource_dir, file), install_dir: exe_dir)
135         endforeach
136         run_command('ln', '-s', join_paths(cef_resource_dir, 'locales/en-US.pak'), join_paths(meson.current_build_dir(), 'locales/'))
137         install_data(join_paths(cef_resource_dir, 'locales/en-US.pak'), install_dir: join_paths(exe_dir, 'locales'))
138 endif
139
140 # bmusb.
141 if embedded_bmusb
142         bmusb_dir = include_directories('bmusb')
143         nageru_include_dirs += bmusb_dir
144
145         bmusb = static_library('bmusb', 'bmusb/bmusb.cpp', 'bmusb/fake_capture.cpp',
146                 dependencies: [libusbdep],
147                 include_directories: [bmusb_dir])
148         nageru_link_with += bmusb
149         kaeru_link_with += bmusb
150 else
151         nageru_deps += bmusbdep
152         kaeru_extra_deps += bmusbdep
153 endif
154
155 # Protobuf compilation.
156 gen = generator(protoc, \
157         output    : ['@BASENAME@.pb.cc', '@BASENAME@.pb.h'],
158         arguments : ['--proto_path=@CURRENT_SOURCE_DIR@', '--cpp_out=@BUILD_DIR@', '@INPUT@'])
159 proto_generated = gen.process(['state.proto', 'midi_mapping.proto', 'json.proto'])
160 protobuf_lib = static_library('protobufs', proto_generated, dependencies: nageru_deps, include_directories: nageru_include_dirs)
161 protobuf_hdrs = declare_dependency(sources: proto_generated)
162 nageru_link_with += protobuf_lib
163
164 # Preprocess Qt as needed.
165 qt_files = qt5.preprocess(
166         moc_headers: ['aboutdialog.h', 'analyzer.h', 'clickable_label.h', 'compression_reduction_meter.h', 'correlation_meter.h',
167                 'ellipsis_label.h', 'glwidget.h', 'input_mapping_dialog.h', 'lrameter.h', 'mainwindow.h', 'midi_mapping_dialog.h',
168                 'nonlinear_fader.h', 'vumeter.h'],
169         ui_files: ['aboutdialog.ui', 'analyzer.ui', 'audio_expanded_view.ui', 'audio_miniview.ui', 'display.ui',
170                 'input_mapping.ui', 'mainwindow.ui', 'midi_mapping.ui'],
171         dependencies: qt5deps)
172
173 # Qt objects.
174 srcs += ['glwidget.cpp', 'mainwindow.cpp', 'vumeter.cpp', 'lrameter.cpp', 'compression_reduction_meter.cpp',
175         'correlation_meter.cpp', 'aboutdialog.cpp', 'analyzer.cpp', 'input_mapping_dialog.cpp', 'midi_mapping_dialog.cpp',
176         'nonlinear_fader.cpp', 'context_menus.cpp', 'vu_common.cpp', 'piecewise_interpolator.cpp', 'midi_mapper.cpp']
177
178 # Auxiliary objects used for nearly everything.
179 aux_srcs = ['metrics.cpp', 'flags.cpp']
180 aux = static_library('aux', aux_srcs, dependencies: nageru_deps, include_directories: nageru_include_dirs)
181 nageru_link_with += aux
182
183 # Audio objects.
184 audio_mixer_srcs = ['audio_mixer.cpp', 'alsa_input.cpp', 'alsa_pool.cpp', 'ebu_r128_proc.cc', 'stereocompressor.cpp',
185         'resampling_queue.cpp', 'flags.cpp', 'correlation_measurer.cpp', 'filter.cpp', 'input_mapping.cpp']
186 audio = static_library('audio', audio_mixer_srcs, dependencies: [nageru_deps, protobuf_hdrs], include_directories: nageru_include_dirs)
187 nageru_link_with += audio
188
189 # Mixer objects.
190 srcs += ['chroma_subsampler.cpp', 'v210_converter.cpp', 'mixer.cpp', 'pbo_frame_allocator.cpp',
191         'context.cpp', 'theme.cpp', 'image_input.cpp', 'alsa_output.cpp',
192         'disk_space_estimator.cpp', 'timecode_renderer.cpp', 'tweaked_inputs.cpp']
193
194 # Streaming and encoding objects (largely the set that is shared between Nageru and Kaeru).
195 stream_srcs = ['quicksync_encoder.cpp', 'x264_encoder.cpp', 'x264_dynamic.cpp', 'x264_speed_control.cpp', 'video_encoder.cpp',
196         'metacube2.cpp', 'mux.cpp', 'audio_encoder.cpp', 'ffmpeg_raii.cpp', 'ffmpeg_util.cpp', 'httpd.cpp', 'ffmpeg_capture.cpp',
197         'print_latency.cpp', 'basic_stats.cpp', 'ref_counted_frame.cpp']
198 stream = static_library('stream', stream_srcs, dependencies: nageru_deps, include_directories: nageru_include_dirs)
199 nageru_link_with += stream
200
201 # DeckLink.
202 srcs += ['decklink_capture.cpp', 'decklink_util.cpp', 'decklink_output.cpp', 'memcpy_interleaved.cpp',
203         'decklink/DeckLinkAPIDispatch.cpp']
204 decklink_dir = include_directories('decklink')
205 nageru_include_dirs += decklink_dir
206
207 # CEF input.
208 if have_cef
209         srcs += ['nageru_cef_app.cpp', 'cef_capture.cpp']
210 endif
211
212 srcs += qt_files
213 srcs += proto_generated
214
215 # Everything except main.cpp. (We do this because if you specify a .cpp file in
216 # both Nageru and Kaeru, it gets compiled twice. In the older Makefiles, Kaeru
217 # depended on a smaller set of objects.)
218 core = static_library('core', srcs, dependencies: nageru_deps, include_directories: nageru_include_dirs)
219 nageru_link_with += core
220
221 # Nageru executable; it goes into /usr/lib/nageru since CEF files go there, too
222 # (we can't put them straight into /usr/bin).
223 executable('nageru', 'main.cpp',
224         dependencies: nageru_deps,
225         include_directories: nageru_include_dirs,
226         link_with: nageru_link_with,
227         link_args: nageru_link_args,
228         build_rpath: nageru_build_rpath,
229         install_rpath: nageru_install_rpath,
230         install: true,
231         install_dir: exe_dir
232 )
233 meson.add_install_script('scripts/setup_nageru_symlink.sh')
234
235 # Kaeru executable.
236 executable('kaeru', 'kaeru.cpp',
237         dependencies: [nageru_deps, kaeru_extra_deps],
238         include_directories: nageru_include_dirs,
239         link_with: [stream, aux, kaeru_link_with],
240         link_args: nageru_link_args,
241         install: true)
242
243 # Audio mixer microbenchmark.
244 executable('benchmark_audio_mixer', 'benchmark_audio_mixer.cpp', dependencies: nageru_deps, include_directories: nageru_include_dirs, link_args: nageru_link_args, link_with: [audio, aux])
245
246 # These are needed for a default run.
247 data_files = ['theme.lua', 'simple.lua', 'bg.jpeg', 'akai_midimix.midimapping']
248 install_data(data_files, install_dir: join_paths(get_option('prefix'), 'share/nageru'))
249 foreach file : data_files
250         run_command('ln', '-s', join_paths(meson.current_source_dir(), file), meson.current_build_dir())
251 endforeach