1 project('gst-plugins-good', 'c',
3 meson_version : '>= 0.60',
4 default_options : [ 'warning_level=1',
5 'buildtype=debugoptimized' ])
7 gst_version = meson.project_version()
8 version_arr = gst_version.split('.')
9 gst_version_major = version_arr[0].to_int()
10 gst_version_minor = version_arr[1].to_int()
11 gst_version_micro = version_arr[2].to_int()
12 if version_arr.length() == 4
13 gst_version_nano = version_arr[3].to_int()
17 gst_version_is_stable = gst_version_minor.is_even()
18 gst_version_is_dev = gst_version_minor.is_odd() and gst_version_micro < 90
20 have_cxx = add_languages('cpp', native: false, required: false)
22 glib_req = '>= 2.62.0'
25 if gst_version_is_stable
26 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
28 gst_req = '>= ' + gst_version
33 plugins_install_dir = join_paths(get_option('libdir'), 'gstreamer-1.0')
35 static_build = get_option('default_library') == 'static'
37 cc = meson.get_compiler('c')
38 host_system = host_machine.system()
40 if cc.get_id() == 'msvc'
42 # Ignore several spurious warnings for things gstreamer does very commonly
43 # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
44 # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
45 # NOTE: Only add warnings here if you are sure they're spurious
46 '/wd4018', # implicit signed/unsigned conversion
47 '/wd4146', # unary minus on unsigned (beware INT_MIN)
48 '/wd4244', # lossy type conversion (e.g. double -> int)
49 '/wd4305', # truncating type conversion (e.g. double -> float)
50 cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
54 # Enable some warnings on MSVC to match GCC/Clang behaviour
55 msvc_args += cc.get_supported_arguments([
56 '/we4002', # too many actual parameters for macro 'identifier'
57 '/we4003', # not enough actual parameters for macro 'identifier'
58 '/we4013', # 'function' undefined; assuming extern returning int
59 '/we4020', # 'function' : too many actual parameters
60 '/we4027', # function declared without formal parameter list
61 '/we4029', # declared formal parameter list different from definition
62 '/we4033', # 'function' must return a value
63 '/we4045', # 'array' : array bounds overflow
64 '/we4047', # 'operator' : 'identifier1' differs in levels of indirection from 'identifier2'
65 '/we4053', # one void operand for '?:'
66 '/we4062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled
67 '/we4098', # 'function' : void function returning a value
68 '/we4101', # 'identifier' : unreferenced local variable
69 '/we4189', # 'identifier' : local variable is initialized but not referenced
73 add_project_arguments(msvc_args, language: ['c', 'cpp'])
75 add_project_arguments(msvc_args, language: 'c')
77 # Disable SAFESEH with MSVC for plugins and libs that use external deps that
78 # are built with MinGW
79 noseh_link_args = ['/SAFESEH:NO']
84 if cc.has_link_argument('-Wl,-Bsymbolic-functions')
85 add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
89 if cc.has_argument('-fvisibility=hidden')
90 add_project_arguments('-fvisibility=hidden', language: 'c')
93 # Disable strict aliasing
94 if cc.has_argument('-fno-strict-aliasing')
95 add_project_arguments('-fno-strict-aliasing', language: 'c')
98 # Define G_DISABLE_DEPRECATED for development versions
100 message('Disabling deprecated GLib API')
101 add_project_arguments('-DG_DISABLE_DEPRECATED', language: 'c')
104 cast_checks = get_option('gobject-cast-checks')
105 if cast_checks.disabled() or (cast_checks.auto() and not gst_version_is_dev)
106 message('Disabling GLib cast checks')
107 add_project_arguments('-DG_DISABLE_CAST_CHECKS', language: 'c')
110 glib_asserts = get_option('glib-asserts')
111 if glib_asserts.disabled() or (glib_asserts.auto() and not gst_version_is_dev)
112 message('Disabling GLib asserts')
113 add_project_arguments('-DG_DISABLE_ASSERT', language: 'c')
116 glib_checks = get_option('glib-checks')
117 if glib_checks.disabled() or (glib_checks.auto() and not gst_version_is_dev)
118 message('Disabling GLib checks')
119 add_project_arguments('-DG_DISABLE_CHECKS', language: 'c')
122 cdata = configuration_data()
123 cdata.set('ENABLE_NLS', 1)
126 ['HAVE_DLFCN_H', 'dlfcn.h'],
127 ['HAVE_FCNTL_H', 'fcntl.h'],
128 ['HAVE_INTTYPES_H', 'inttypes.h'],
129 ['HAVE_MEMORY_H', 'memory.h'],
130 ['HAVE_PROCESS_H', 'process.h'],
131 ['HAVE_STDINT_H', 'stdint.h'],
132 ['HAVE_STDLIB_H', 'stdlib.h'],
133 ['HAVE_STRINGS_H', 'strings.h'],
134 ['HAVE_STRING_H', 'string.h'],
135 ['HAVE_SYS_IOCTL_H', 'sys/ioctl.h'],
136 ['HAVE_SYS_PARAM_H', 'sys/param.h'],
137 ['HAVE_SYS_SOCKET_H', 'sys/socket.h'],
138 ['HAVE_SYS_STAT_H', 'sys/stat.h'],
139 ['HAVE_SYS_TIME_H', 'sys/time.h'],
140 ['HAVE_SYS_TYPES_H', 'sys/types.h'],
141 ['HAVE_UNISTD_H', 'unistd.h'],
144 foreach h : check_headers
145 if cc.has_header(h.get(1))
146 cdata.set(h.get(0), 1)
151 ['HAVE_ASINH', 'asinh', '#include<math.h>'],
152 ['HAVE_CLOCK_GETTIME', 'clock_gettime', '#include<time.h>'],
153 ['HAVE_COSH', 'cosh', '#include<math.h>'],
154 # check token HAVE_CPU_ALPHA
155 # check token HAVE_CPU_ARM
156 # check token HAVE_CPU_CRIS
157 # check token HAVE_CPU_CRISV32
158 # check token HAVE_CPU_HPPA
159 # check token HAVE_CPU_I386
160 # check token HAVE_CPU_IA64
161 # check token HAVE_CPU_M68K
162 # check token HAVE_CPU_MIPS
163 # check token HAVE_CPU_PPC
164 # check token HAVE_CPU_PPC64
165 # check token HAVE_CPU_S390
166 # check token HAVE_CPU_SPARC
167 # check token HAVE_CPU_X86_64
168 ['HAVE_DCGETTEXT', 'dcgettext', '#include<libintl.h>'],
169 # check token HAVE_DIRECTSOUND
170 # check token HAVE_EXPERIMENTAL
171 # check token HAVE_EXTERNAL
172 # check token HAVE_FPCLASS
173 # check token HAVE_GCC_ASM
174 ['HAVE_GETPAGESIZE', 'getpagesize', '#include<unistd.h>'],
175 # check token HAVE_GETTEXT
176 # check token HAVE_GST_V4L2
177 ['HAVE_ISINF', 'isinf', '#include<math.h>'],
178 # check token HAVE_LIBV4L2
179 ['HAVE_MMAP', 'mmap', '#include<sys/mman.h>'],
180 ['HAVE_MMAP64', 'mmap64', '#include<sys/mman.h>'],
181 # check token HAVE_OSX_AUDIO
182 # check token HAVE_OSX_VIDEO
183 # check token HAVE_RDTSC
184 ['HAVE_SINH', 'sinh', '#include<math.h>'],
185 # check token HAVE_WAVEFORM
186 ['HAVE_GMTIME_R', 'gmtime_r', '#include<time.h>'],
189 libm = cc.find_library('m', required : false)
191 foreach f : check_functions
192 if cc.has_function(f.get(1), prefix : f.get(2), dependencies : libm)
193 cdata.set(f.get(0), 1)
197 cdata.set('HAVE_IOS', host_system == 'ios')
199 cdata.set('SIZEOF_CHAR', cc.sizeof('char'))
200 cdata.set('SIZEOF_INT', cc.sizeof('int'))
201 cdata.set('SIZEOF_LONG', cc.sizeof('long'))
202 cdata.set('SIZEOF_SHORT', cc.sizeof('short'))
203 cdata.set('SIZEOF_VOIDP', cc.sizeof('void*'))
204 cdata.set('SIZEOF_OFF_T', cc.sizeof('off_t'))
206 have_rtld_noload = cc.has_header_symbol('dlfcn.h', 'RTLD_NOLOAD')
207 cdata.set('HAVE_RTLD_NOLOAD', have_rtld_noload)
210 # FIXME: check if this is correct
211 cdata.set('HAVE_CPU_X86_64', host_machine.cpu() == 'amd64')
212 cdata.set('HAVE_GCC_ASM', cc.get_id() != 'msvc')
213 cdata.set_quoted('VERSION', gst_version)
214 cdata.set_quoted('PACKAGE_VERSION', gst_version)
215 cdata.set_quoted('GST_LICENSE', 'LGPL')
216 cdata.set_quoted('PACKAGE', 'gst-plugins-good')
217 cdata.set_quoted('GETTEXT_PACKAGE', 'gst-plugins-good-1.0')
218 cdata.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
221 '-Wmissing-declarations',
225 '-Wmissing-include-dirs',
232 '-Wmissing-prototypes',
233 '-Wold-style-definition',
234 '-Waggregate-return',
238 cxx = meson.get_compiler('cpp')
241 foreach extra_arg : warning_flags
242 if cc.has_argument (extra_arg)
243 add_project_arguments([extra_arg], language: 'c')
245 if have_cxx and cxx.has_argument (extra_arg)
246 add_project_arguments([extra_arg], language: 'cpp')
250 foreach extra_arg : warning_c_flags
251 if cc.has_argument (extra_arg)
252 add_project_arguments([extra_arg], language: 'c')
256 # GStreamer package name and origin url
257 gst_package_name = get_option('package-name')
258 if gst_package_name == ''
259 if gst_version_nano == 0
260 gst_package_name = 'GStreamer Good Plug-ins source release'
261 elif gst_version_nano == 1
262 gst_package_name = 'GStreamer Good Plug-ins git'
264 gst_package_name = 'GStreamer Good Plug-ins prerelease'
267 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
268 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
271 gst_dep = dependency('gstreamer-1.0', version : gst_req,
272 fallback : ['gstreamer', 'gst_dep'])
273 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
274 fallback : ['gstreamer', 'gst_base_dep'])
275 gstnet_dep = dependency('gstreamer-net-1.0', version : gst_req,
276 fallback : ['gstreamer', 'gst_net_dep'])
277 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
278 fallback : ['gstreamer', 'gst_controller_dep'])
279 gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
280 required : get_option('tests'),
281 fallback : ['gstreamer', 'gst_check_dep'])
282 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
283 fallback : ['gst-plugins-base', 'pbutils_dep'])
284 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
285 fallback : ['gst-plugins-base', 'allocators_dep'])
286 gstapp_dep = dependency('gstreamer-app-1.0', version : gst_req,
287 fallback : ['gst-plugins-base', 'app_dep'])
288 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
289 fallback : ['gst-plugins-base', 'audio_dep'])
290 gstfft_dep = dependency('gstreamer-fft-1.0', version : gst_req,
291 fallback : ['gst-plugins-base', 'fft_dep'])
292 gstriff_dep = dependency('gstreamer-riff-1.0', version : gst_req,
293 fallback : ['gst-plugins-base', 'riff_dep'])
294 gstrtp_dep = dependency('gstreamer-rtp-1.0', version : gst_req,
295 fallback : ['gst-plugins-base', 'rtp_dep'])
296 gstrtsp_dep = dependency('gstreamer-rtsp-1.0', version : gst_req,
297 fallback : ['gst-plugins-base', 'rtsp_dep'])
298 gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
299 fallback : ['gst-plugins-base', 'sdp_dep'])
300 gsttag_dep = dependency('gstreamer-tag-1.0', version : gst_req,
301 fallback : ['gst-plugins-base', 'tag_dep'])
302 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
303 fallback : ['gst-plugins-base', 'video_dep'])
307 gstgl_dep = dependency('gstreamer-gl-1.0', version : gst_req,
308 fallback : ['gst-plugins-base', 'gstgl_dep'], required: false)
309 gstglproto_dep = dependency('', required : false)
310 gstglx11_dep = dependency('', required : false)
311 gstglwayland_dep = dependency('', required : false)
312 gstglegl_dep = dependency('', required : false)
314 have_gstgl = gstgl_dep.found()
317 if gstgl_dep.type_name() == 'pkgconfig'
318 gst_gl_apis = gstgl_dep.get_variable('gl_apis').split()
319 gst_gl_winsys = gstgl_dep.get_variable('gl_winsys').split()
320 gst_gl_platforms = gstgl_dep.get_variable('gl_platforms').split()
322 gstbase = subproject('gst-plugins-base')
323 gst_gl_apis = gstbase.get_variable('enabled_gl_apis')
324 gst_gl_winsys = gstbase.get_variable('enabled_gl_winsys')
325 gst_gl_platforms = gstbase.get_variable('enabled_gl_platforms')
328 message('GStreamer OpenGL window systems: @0@'.format(' '.join(gst_gl_winsys)))
329 message('GStreamer OpenGL platforms: @0@'.format(' '.join(gst_gl_platforms)))
330 message('GStreamer OpenGL apis: @0@'.format(' '.join(gst_gl_apis)))
332 foreach ws : ['x11', 'wayland', 'android', 'cocoa', 'eagl', 'win32', 'dispmanx', 'viv_fb']
333 set_variable('gst_gl_have_window_@0@'.format(ws), gst_gl_winsys.contains(ws))
336 foreach p : ['glx', 'egl', 'cgl', 'eagl', 'wgl']
337 set_variable('gst_gl_have_platform_@0@'.format(p), gst_gl_platforms.contains(p))
340 foreach api : ['gl', 'gles2']
341 set_variable('gst_gl_have_api_@0@'.format(api), gst_gl_apis.contains(api))
344 gstglproto_dep = dependency('gstreamer-gl-prototypes-1.0', version : gst_req,
345 fallback : ['gst-plugins-base', 'gstglproto_dep'], required: true)
346 # Behind specific checks because meson fails at optional dependencies with a
347 # fallback to the same subproject. On the first failure, meson will never
348 # check the system again even if the fallback never existed.
349 # Last checked with meson 0.54.3
350 if gst_gl_have_window_x11
351 gstglx11_dep = dependency('gstreamer-gl-x11-1.0', version : gst_req,
352 fallback : ['gst-plugins-base', 'gstglx11_dep'], required: true)
354 if gst_gl_have_window_wayland
355 gstglwayland_dep = dependency('gstreamer-gl-wayland-1.0', version : gst_req,
356 fallback : ['gst-plugins-base', 'gstglwayland_dep'], required: true)
358 if gst_gl_have_platform_egl
359 gstglegl_dep = dependency('gstreamer-gl-egl-1.0', version : gst_req,
360 fallback : ['gst-plugins-base', 'gstglegl_dep'], required: true)
364 zlib_dep = dependency('zlib')
365 cdata.set('HAVE_ZLIB', true)
367 gio_dep = dependency('gio-2.0', version: glib_req)
368 gmodule_dep = dependency('gmodule-no-export-2.0')
370 gst_plugins_good_args = ['-DHAVE_CONFIG_H']
371 configinc = include_directories('.')
372 libsinc = include_directories('gst-libs')
377 # Used by various libraries/elements that use Orc code
378 orc_dep = dependency('orc-0.4', version : orc_req, required : get_option('orc'),
379 fallback : ['orc', 'orc_dep'])
380 orcc = find_program('orcc', required : get_option('orc'))
381 if orc_dep.found() and orcc.found()
383 orcc_args = [orcc, '--include', 'glib.h']
384 cdata.set('HAVE_ORC', 1)
386 message('Orc Compiler not found, will use backup C code')
387 cdata.set('DISABLE_ORC', 1)
391 # FIXME: nasm path needs testing on non-Linux, esp. Windows
392 host_cpu = host_machine.cpu_family()
393 if host_cpu == 'x86_64'
394 if cc.get_define('__ILP32__') == '1'
395 message('Nasm disabled on x32')
397 asm_option = get_option('asm')
398 nasm = find_program('nasm', native: true, required: asm_option)
400 # We can't use the version: kwarg for find_program because old versions
401 # of nasm don't support --version
402 ret = run_command(nasm, '-v', check: false)
403 if ret.returncode() == 0
404 nasm_version = ret.stdout().strip().split()[2]
406 if nasm_version.version_compare(nasm_req)
407 message('nasm found on x86-64')
408 cdata.set('HAVE_NASM', 1)
411 if asm_option.enabled()
412 error('asm option is enabled, and nasm @0@ was found, but @1@ is required'.format(nasm_version, nasm_req))
414 message('nasm @0@ was found, but @1@ is required'.format(nasm_version, nasm_req))
417 if asm_option.enabled()
418 error('asm option is enabled, but nasm is not usable: @0@\n@1@'.format(ret.stdout(), ret.stderr()))
420 message('nasm was found, but it\'s not usable')
422 # Unset nasm to not be 'found'
430 # Disable compiler warnings for unused variables and args if gst debug system is disabled
431 if gst_dep.type_name() == 'internal'
432 gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
434 # We can't check that in the case of subprojects as we won't
435 # be able to build against an internal dependency (which is not built yet)
436 gst_debug_disabled = cc.has_header_symbol('gst/gstconfig.h', 'GST_DISABLE_GST_DEBUG', dependencies: gst_dep)
439 if gst_debug_disabled
440 message('GStreamer debug system is disabled')
441 if cc.has_argument('-Wno-unused')
442 add_project_arguments('-Wno-unused', language: 'c')
444 if have_cxx and cxx.has_argument ('-Wno-unused')
445 add_project_arguments('-Wno-unused', language: 'cpp')
448 message('GStreamer debug system is enabled')
451 presetdir = join_paths(get_option('datadir'), 'gstreamer-' + api_version, 'presets')
453 python3 = import('python').find_installation()
454 pkgconfig = import('pkgconfig')
455 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
456 if get_option('default_library') == 'shared'
457 # If we don't build static plugins there is no need to generate pc files
458 plugins_pkgconfig_install_dir = disabler()
467 if have_orcc and orc_targets.length() > 0
468 update_orc_dist_files = find_program('scripts/update-orc-dist-files.py')
470 orc_update_targets = []
471 foreach t : orc_targets
472 orc_name = t.get('name')
473 orc_file = t.get('orc-source')
474 header = t.get('header')
475 source = t.get('source')
476 # alias_target() only works with build targets, so can't use run_target() here
477 orc_update_targets += [
478 custom_target('update-orc-@0@'.format(orc_name),
479 input: [header, source],
480 command: [update_orc_dist_files, orc_file, header, source],
481 output: ['@0@-dist.c'.format(orc_name)]) # not entirely true
485 if orc_update_targets.length() > 0
486 update_orc_dist_target = alias_target('update-orc-dist', orc_update_targets)
490 # xgettext is optional (on Windows for instance)
491 if find_program('xgettext', required : get_option('nls')).found()
498 if gst_version_nano == 0
499 extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
500 run_result = run_command(extract_release_date, gst_version, files('gst-plugins-good.doap'), check: true)
501 release_date = run_result.stdout().strip()
502 cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
503 message('Package release date: ' + release_date)
506 if gio_dep.version().version_compare('< 2.67.4')
507 cdata.set('g_memdup2(ptr,sz)', '(G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(),NULL)')
510 configure_file(output : 'config.h', configuration : cdata)
514 foreach plugin: plugins
515 dep = declare_dependency(link_with: plugin, variables: {'full_path': plugin.full_path()})
516 meson.override_dependency(plugin.name(), dep)
518 if plugin.name().startswith('gst')
519 plugin_names += [plugin.name().substring(3)]
521 plugin_names += [plugin.name()]
526 'Plugins': plugin_names,