1 project('gst-plugins-bad', 'c', 'cpp',
3 meson_version : '>= 0.54',
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_dev = gst_version_minor % 2 == 1 and gst_version_micro < 90
19 glib_req = '>= 2.56.0'
21 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
25 # maintaining compatibility with the previous libtool versioning
26 # current = minor * 100 + micro
27 curversion = gst_version_minor * 100 + gst_version_micro
28 libversion = '@0@.@1@.0'.format(soversion, curversion)
29 osxversion = curversion + 1
31 plugins_install_dir = join_paths(get_option('libdir'), 'gstreamer-1.0')
34 cc = meson.get_compiler('c')
35 cxx = meson.get_compiler('cpp')
36 host_system = host_machine.system()
38 if host_system in ['ios', 'darwin']
39 have_objc = add_languages('objc', native: false)
40 have_objcpp = add_languages('objcpp', native: false)
46 cdata = configuration_data()
48 if cc.get_id() == 'msvc'
50 # Ignore several spurious warnings for things gstreamer does very commonly
51 # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
52 # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
53 # NOTE: Only add warnings here if you are sure they're spurious
54 '/wd4018', # implicit signed/unsigned conversion
55 '/wd4146', # unary minus on unsigned (beware INT_MIN)
56 '/wd4244', # lossy type conversion (e.g. double -> int)
57 '/wd4305', # truncating type conversion (e.g. double -> float)
58 cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
60 # Enable some warnings on MSVC to match GCC/Clang behaviour
61 '/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled
62 '/w14101', # 'identifier' : unreferenced local variable
63 '/w14189', # 'identifier' : local variable is initialized but not referenced
65 add_project_arguments(msvc_args, language: ['c', 'cpp'])
66 # Disable SAFESEH with MSVC for plugins and libs that use external deps that
67 # are built with MinGW
68 noseh_link_args = ['/SAFESEH:NO']
70 if cxx.has_argument('-Wno-non-virtual-dtor')
71 add_project_arguments('-Wno-non-virtual-dtor', language: 'cpp')
77 if cc.has_link_argument('-Wl,-Bsymbolic-functions')
78 add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
82 if cc.get_id() == 'msvc'
83 export_define = '__declspec(dllexport) extern'
84 elif cc.has_argument('-fvisibility=hidden')
85 add_project_arguments('-fvisibility=hidden', language: 'c')
86 add_project_arguments('-fvisibility=hidden', language: 'cpp')
88 add_project_arguments('-fvisibility=hidden', language: 'objc')
90 export_define = 'extern __attribute__ ((visibility ("default")))'
92 export_define = 'extern'
95 # Passing this through the command line would be too messy
96 cdata.set('GST_API_EXPORT', export_define)
98 # Disable strict aliasing
99 if cc.has_argument('-fno-strict-aliasing')
100 add_project_arguments('-fno-strict-aliasing', language: 'c')
102 if cxx.has_argument('-fno-strict-aliasing')
103 add_project_arguments('-fno-strict-aliasing', language: 'cpp')
106 # Define G_DISABLE_DEPRECATED for development versions
107 if gst_version_is_dev
108 message('Disabling deprecated GLib API')
109 add_project_arguments('-DG_DISABLE_DEPRECATED', language: 'c')
112 cast_checks = get_option('gobject-cast-checks')
113 if cast_checks.disabled() or (cast_checks.auto() and not gst_version_is_dev)
114 message('Disabling GLib cast checks')
115 add_project_arguments('-DG_DISABLE_CAST_CHECKS', language: 'c')
118 glib_asserts = get_option('glib-asserts')
119 if glib_asserts.disabled() or (glib_asserts.auto() and not gst_version_is_dev)
120 message('Disabling GLib asserts')
121 add_project_arguments('-DG_DISABLE_ASSERT', language: 'c')
124 glib_checks = get_option('glib-checks')
125 if glib_checks.disabled() or (glib_checks.auto() and not gst_version_is_dev)
126 message('Disabling GLib checks')
127 add_project_arguments('-DG_DISABLE_CHECKS', language: 'c')
131 ['HAVE_DLFCN_H', 'dlfcn.h'],
132 ['HAVE_FCNTL_H', 'fcntl.h'],
133 ['HAVE_INTTYPES_H', 'inttypes.h'],
134 ['HAVE_MEMORY_H', 'memory.h'],
135 ['HAVE_NETINET_IN_H', 'netinet/in.h'],
136 ['HAVE_NETINET_IP_H', 'netinet/ip.h'],
137 ['HAVE_NETINET_TCP_H', 'netinet/tcp.h'],
138 ['HAVE_PTHREAD_H', 'pthread.h'],
139 ['HAVE_STDINT_H', 'stdint.h'],
140 ['HAVE_STDLIB_H', 'stdlib.h'],
141 ['HAVE_STRINGS_H', 'strings.h'],
142 ['HAVE_STRING_H', 'string.h'],
143 ['HAVE_SYS_PARAM_H', 'sys/param.h'],
144 ['HAVE_SYS_SOCKET_H', 'sys/socket.h'],
145 ['HAVE_SYS_STAT_H', 'sys/stat.h'],
146 ['HAVE_SYS_TIME_H', 'sys/time.h'],
147 ['HAVE_SYS_TYPES_H', 'sys/types.h'],
148 ['HAVE_SYS_UTSNAME_H', 'sys/utsname.h'],
149 ['HAVE_UNISTD_H', 'unistd.h'],
150 ['HAVE_WINDOWS_H', 'windows.h'],
151 ['HAVE_WINSOCK2_H', 'winsock2.h'],
152 ['HAVE_WS2TCPIP_H', 'ws2tcpip.h'],
155 foreach h : check_headers
156 if cc.has_header(h.get(1))
157 cdata.set(h.get(0), 1)
162 ['HAVE_DCGETTEXT', 'dcgettext'],
163 ['HAVE_GETPAGESIZE', 'getpagesize'],
164 ['HAVE_GMTIME_R', 'gmtime_r'],
165 ['HAVE_MEMFD_CREATE', 'memfd_create'],
166 ['HAVE_MMAP', 'mmap'],
167 ['HAVE_PIPE2', 'pipe2'],
168 ['HAVE_GETRUSAGE', 'getrusage', '#include<sys/resource.h>'],
171 foreach f : check_functions
176 if cc.has_function(f.get(1), prefix: prefix)
177 cdata.set(f.get(0), 1)
181 cdata.set('SIZEOF_CHAR', cc.sizeof('char'))
182 cdata.set('SIZEOF_INT', cc.sizeof('int'))
183 cdata.set('SIZEOF_LONG', cc.sizeof('long'))
184 cdata.set('SIZEOF_SHORT', cc.sizeof('short'))
185 cdata.set('SIZEOF_VOIDP', cc.sizeof('void*'))
187 cdata.set_quoted('VERSION', gst_version)
188 cdata.set_quoted('PACKAGE', 'gst-plugins-bad')
189 cdata.set_quoted('PACKAGE_VERSION', gst_version)
190 cdata.set_quoted('PACKAGE_BUGREPORT', 'https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/new')
191 cdata.set_quoted('PACKAGE_NAME', 'GStreamer Bad Plug-ins')
192 cdata.set_quoted('GETTEXT_PACKAGE', 'gst-plugins-bad-1.0')
193 cdata.set_quoted('GST_API_VERSION', api_version)
194 cdata.set_quoted('GST_LICENSE', 'LGPL')
195 cdata.set_quoted('LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
196 cdata.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
199 '-Wmissing-declarations',
205 '-Wmissing-include-dirs',
213 '-Wmissing-prototypes',
214 '-Wdeclaration-after-statement',
215 '-Wold-style-definition',
218 warning_cxx_flags = [
219 '-Wformat-nonliteral',
222 foreach extra_arg : warning_c_flags
223 if cc.has_argument (extra_arg)
224 add_project_arguments([extra_arg], language: 'c')
228 foreach extra_arg : warning_cxx_flags
229 if cxx.has_argument (extra_arg)
230 add_project_arguments([extra_arg], language: 'cpp')
234 foreach extra_arg : warning_flags
235 if cc.has_argument (extra_arg)
236 add_project_arguments([extra_arg], language: 'c')
238 if cxx.has_argument (extra_arg)
239 add_project_arguments([extra_arg], language: 'cpp')
243 # GStreamer package name and origin url
244 gst_package_name = get_option('package-name')
245 if gst_package_name == ''
246 if gst_version_nano == 0
247 gst_package_name = 'GStreamer Bad Plug-ins source release'
248 elif gst_version_nano == 1
249 gst_package_name = 'GStreamer Bad Plug-ins git'
251 gst_package_name = 'GStreamer Bad Plug-ins prerelease'
254 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
255 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
257 # FIXME: This should be exposed as a configuration option
258 if host_system == 'linux'
259 cdata.set_quoted('DEFAULT_VIDEOSRC', 'v4l2src')
260 elif ['darwin', 'ios'].contains(host_system)
261 cdata.set_quoted('DEFAULT_VIDEOSRC', 'avfvideosrc')
262 cdata.set_quoted('GST_EXTRA_MODULE_SUFFIX', '.dylib')
263 # Yes, we set this for iOS too. Same as Autotools.
264 cdata.set('HAVE_OSX', 1)
266 cdata.set_quoted('DEFAULT_VIDEOSRC', 'videotestsrc')
270 gst_dep = dependency('gstreamer-1.0', version : gst_req,
271 fallback : ['gstreamer', 'gst_dep'])
272 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
273 fallback : ['gstreamer', 'gst_base_dep'])
274 gstnet_dep = dependency('gstreamer-net-1.0', version : gst_req,
275 fallback : ['gstreamer', 'gst_net_dep'])
276 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
277 fallback : ['gstreamer', 'gst_controller_dep'])
279 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
280 fallback : ['gst-plugins-base', 'pbutils_dep'])
281 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
282 fallback : ['gst-plugins-base', 'allocators_dep'])
283 gstapp_dep = dependency('gstreamer-app-1.0', version : gst_req,
284 fallback : ['gst-plugins-base', 'app_dep'])
285 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
286 fallback : ['gst-plugins-base', 'audio_dep'])
287 gstfft_dep = dependency('gstreamer-fft-1.0', version : gst_req,
288 fallback : ['gst-plugins-base', 'fft_dep'])
289 gstriff_dep = dependency('gstreamer-riff-1.0', version : gst_req,
290 fallback : ['gst-plugins-base', 'riff_dep'])
291 gstrtp_dep = dependency('gstreamer-rtp-1.0', version : gst_req,
292 fallback : ['gst-plugins-base', 'rtp_dep'])
293 gstrtsp_dep = dependency('gstreamer-rtsp-1.0', version : gst_req,
294 fallback : ['gst-plugins-base', 'rtsp_dep'])
295 gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
296 fallback : ['gst-plugins-base', 'sdp_dep'])
297 gsttag_dep = dependency('gstreamer-tag-1.0', version : gst_req,
298 fallback : ['gst-plugins-base', 'tag_dep'])
299 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
300 fallback : ['gst-plugins-base', 'video_dep'])
301 gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
302 required : get_option('tests'),
303 fallback : ['gstreamer', 'gst_check_dep'])
306 gstgl_dep = dependency('gstreamer-gl-1.0', version : gst_req,
307 fallback : ['gst-plugins-base', 'gstgl_dep'], required: get_option('gl'))
308 gstglproto_dep = dependency('gstreamer-gl-prototypes-1.0', version : gst_req,
309 fallback : ['gst-plugins-base', 'gstglproto_dep'], required: get_option('gl'))
310 gstglx11_dep = dependency('', required : false)
311 gstglwayland_dep = dependency('', required : false)
312 gstglegl_dep = dependency('', required : false)
315 if gstgl_dep.type_name() == 'pkgconfig'
316 gst_gl_apis = gstgl_dep.get_pkgconfig_variable('gl_apis').split()
317 gst_gl_winsys = gstgl_dep.get_pkgconfig_variable('gl_winsys').split()
318 gst_gl_platforms = gstgl_dep.get_pkgconfig_variable('gl_platforms').split()
320 gstbase = subproject('gst-plugins-base')
321 gst_gl_apis = gstbase.get_variable('enabled_gl_apis')
322 gst_gl_winsys = gstbase.get_variable('enabled_gl_winsys')
323 gst_gl_platforms = gstbase.get_variable('enabled_gl_platforms')
326 message('GStreamer OpenGL window systems: @0@'.format(' '.join(gst_gl_winsys)))
327 message('GStreamer OpenGL platforms: @0@'.format(' '.join(gst_gl_platforms)))
328 message('GStreamer OpenGL apis: @0@'.format(' '.join(gst_gl_apis)))
330 foreach ws : ['x11', 'wayland', 'android', 'cocoa', 'eagl', 'win32', 'dispmanx', 'viv_fb']
331 set_variable('gst_gl_have_window_@0@'.format(ws), gst_gl_winsys.contains(ws))
334 foreach p : ['glx', 'egl', 'cgl', 'eagl', 'wgl']
335 set_variable('gst_gl_have_platform_@0@'.format(p), gst_gl_platforms.contains(p))
338 foreach api : ['gl', 'gles2']
339 set_variable('gst_gl_have_api_@0@'.format(api), gst_gl_apis.contains(api))
342 # Behind specific checks because meson fails at optional dependencies with a
343 # fallback to the same subproject. On the first failure, meson will never
344 # check the system again even if the fallback never existed.
345 # Last checked with meson 0.54.3
346 if gst_gl_have_window_x11
347 gstglx11_dep = dependency('gstreamer-gl-x11-1.0', version : gst_req,
348 fallback : ['gst-plugins-base', 'gstglx11_dep'], required: true)
350 if gst_gl_have_window_wayland
351 gstglwayland_dep = dependency('gstreamer-gl-wayland-1.0', version : gst_req,
352 fallback : ['gst-plugins-base', 'gstglwayland_dep'], required: true)
354 if gst_gl_have_platform_egl
355 gstglegl_dep = dependency('gstreamer-gl-egl-1.0', version : gst_req,
356 fallback : ['gst-plugins-base', 'gstglegl_dep'], required: true)
360 libm = cc.find_library('m', required : false)
361 glib_dep = dependency('glib-2.0', version : glib_req, fallback: ['glib', 'libglib_dep'])
362 gmodule_dep = dependency('gmodule-2.0', fallback: ['glib', 'libgmodule_dep'])
363 gio_dep = dependency('gio-2.0', fallback: ['glib', 'libgio_dep'])
364 # gio-unix-2.0 is used by sys/bluez
366 # Optional dep of ext/gl and gst/librfb
367 x11_dep = dependency('x11', required : get_option('x11'))
369 cdata.set('HAVE_X11', 1)
372 if host_machine.system() == 'windows'
373 winsock2 = [cc.find_library('ws2_32')]
378 if ['darwin', 'ios'].contains(host_system)
380 error('Building on MacOS/iOS/etc requires an ObjC compiler')
382 if host_system == 'ios'
383 cdata.set('HAVE_IOS', 1)
386 avfoundation_dep = dependency('AVFoundation', required : false)
387 if avfoundation_dep.found()
388 cdata.set('HAVE_AVFOUNDATION', 1)
391 videotoolbox_dep = dependency('VideoToolbox', required : false)
392 if videotoolbox_dep.found()
393 cdata.set('HAVE_VIDEOTOOLBOX', 1)
396 # FIXME: framework.version() returns 'unknown'
397 # if videotoolbox_dep.version().version_compare('>=10.9.6')
398 # cdata.set('HAVE_VIDEOTOOLBOX_10_9_6', 1)
405 # Used by various libraries/elements that use Orc code
406 orc_dep = dependency('orc-0.4', version : orc_req, required : get_option('orc'),
407 fallback : ['orc', 'orc_dep'])
408 orcc = find_program('orcc', required : get_option('orc'))
409 if orc_dep.found() and orcc.found()
411 orcc_args = [orcc, '--include', 'glib.h']
412 cdata.set('HAVE_ORC', 1)
414 message('Orc Compiler not found or disabled, will use backup C code')
415 cdata.set('DISABLE_ORC', 1)
417 cdata.set('GST_ENABLE_EXTRA_CHECKS', not get_option('extra-checks').disabled())
419 gnustl_dep = declare_dependency()
420 if host_system == 'android'
421 gnustl_dep = dependency('gnustl', required : false)
424 # Disable compiler warnings for unused variables and args if gst debug system is disabled
425 if gst_dep.type_name() == 'internal'
426 gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
428 # We can't check that in the case of subprojects as we won't
429 # be able to build against an internal dependency (which is not built yet)
430 gst_debug_disabled = cc.has_header_symbol('gst/gstconfig.h', 'GST_DISABLE_GST_DEBUG', dependencies: gst_dep)
433 if gst_debug_disabled
434 message('GStreamer debug system is disabled')
435 if cc.has_argument('-Wno-unused')
436 add_project_arguments('-Wno-unused', language: 'c')
438 if cxx.has_argument ('-Wno-unused')
439 add_project_arguments('-Wno-unused', language: 'cpp')
442 message('GStreamer debug system is enabled')
445 gst_plugins_bad_args = ['-DHAVE_CONFIG_H']
446 configinc = include_directories('.')
447 libsinc = include_directories('gst-libs')
449 python3 = import('python').find_installation()
451 gir = find_program('g-ir-scanner', required : get_option('introspection'))
452 gnome = import('gnome')
453 build_gir = gir.found() and (not meson.is_cross_build() or get_option('introspection').enabled())
454 gir_init_section = [ '--add-init-section=extern void gst_init(gint*,gchar**);' + \
455 'g_setenv("GST_REGISTRY_1.0", "@0@", TRUE);'.format(meson.current_build_dir() + '/gir_empty_registry.reg') + \
456 'g_setenv("GST_PLUGIN_PATH_1_0", "", TRUE);' + \
457 'g_setenv("GST_PLUGIN_SYSTEM_PATH_1_0", "", TRUE);' + \
458 'gst_init(NULL,NULL);', '--quiet']
460 presetdir = join_paths(get_option('datadir'), 'gstreamer-' + api_version, 'presets')
462 pkgconfig = import('pkgconfig')
463 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
464 if get_option('default_library') == 'shared'
465 # If we don't build static plugins there is no need to generate pc files
466 plugins_pkgconfig_install_dir = disabler()
469 pkgconfig_variables = ['exec_prefix=${prefix}',
470 'toolsdir=${exec_prefix}/bin',
471 'pluginsdir=${libdir}/gstreamer-1.0',
472 'datarootdir=${prefix}/share',
473 'datadir=${datarootdir}',
474 'girdir=${datadir}/gir-1.0',
475 'typelibdir=${libdir}/girepository-1.0']
477 pkgconfig_subdirs = ['gstreamer-1.0']
480 libraries : [gst_dep],
481 variables : pkgconfig_variables,
482 subdirs : pkgconfig_subdirs,
483 name : 'gstreamer-plugins-bad-1.0',
484 description : 'Streaming media framework, bad plugins libraries',
496 update_orc_dist_files = find_program('scripts/update-orc-dist-files.py')
498 orc_update_targets = []
499 foreach t : orc_targets
500 orc_name = t.get('name')
501 orc_file = t.get('orc-source')
502 header = t.get('header')
503 source = t.get('source')
504 # alias_target() only works with build targets, so can't use run_target() here
505 orc_update_targets += [
506 custom_target('update-orc-@0@'.format(orc_name),
507 input: [header, source],
508 command: [update_orc_dist_files, orc_file, header, source],
509 output: ['@0@-dist.c'.format(orc_name)]) # not entirely true
513 if meson.version().version_compare('>= 0.52') and orc_update_targets.length() > 0
514 update_orc_dist_target = alias_target('update-orc-dist', orc_update_targets)
518 # xgettext is optional (on Windows for instance)
519 if find_program('xgettext', required : get_option('nls')).found()
520 cdata.set('ENABLE_NLS', 1)
527 if gst_version_nano == 0
528 extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
529 run_result = run_command(extract_release_date, gst_version, files('gst-plugins-bad.doap'))
530 if run_result.returncode() == 0
531 release_date = run_result.stdout().strip()
532 cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
533 message('Package release date: ' + release_date)
535 # Error out if our release can't be found in the .doap file
536 error(run_result.stderr())
540 configure_file(output : 'config.h', configuration : cdata)
542 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')
546 if meson.version().version_compare('>= 0.54')
548 foreach plugin: plugins
549 # FIXME: Use str.subtring() when we can depend on Meson 0.56
550 split = plugin.name().split('gst')
551 if split.length() == 2
552 plugin_names += [split[1]]
554 warning('Need substring API in meson >= 0.56 to properly parse plugin name: ' + plugin.name())
555 plugin_names += [plugin.name()]
558 summary({'Plugins':plugin_names}, list_sep: ', ')