1 project('gst-plugins-good', 'c',
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 have_cxx = add_languages('cpp', native: false, required: false)
21 glib_req = '>= 2.56.0'
23 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
27 plugins_install_dir = join_paths(get_option('libdir'), 'gstreamer-1.0')
30 cc = meson.get_compiler('c')
31 host_system = host_machine.system()
33 if cc.get_id() == 'msvc'
35 # Ignore several spurious warnings for things gstreamer does very commonly
36 # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
37 # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
38 # NOTE: Only add warnings here if you are sure they're spurious
39 '/wd4018', # implicit signed/unsigned conversion
40 '/wd4146', # unary minus on unsigned (beware INT_MIN)
41 '/wd4244', # lossy type conversion (e.g. double -> int)
42 '/wd4305', # truncating type conversion (e.g. double -> float)
43 cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
45 # Enable some warnings on MSVC to match GCC/Clang behaviour
46 '/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled
47 '/w14101', # 'identifier' : unreferenced local variable
48 '/w14189', # 'identifier' : local variable is initialized but not referenced
51 add_project_arguments(msvc_args, language: ['c', 'cpp'])
53 add_project_arguments(msvc_args, language: 'c')
55 # Disable SAFESEH with MSVC for plugins and libs that use external deps that
56 # are built with MinGW
57 noseh_link_args = ['/SAFESEH:NO']
62 if cc.has_link_argument('-Wl,-Bsymbolic-functions')
63 add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
67 if cc.has_argument('-fvisibility=hidden')
68 add_project_arguments('-fvisibility=hidden', language: 'c')
71 # Disable strict aliasing
72 if cc.has_argument('-fno-strict-aliasing')
73 add_project_arguments('-fno-strict-aliasing', language: 'c')
76 # Define G_DISABLE_DEPRECATED for development versions
78 message('Disabling deprecated GLib API')
79 add_project_arguments('-DG_DISABLE_DEPRECATED', language: 'c')
82 cast_checks = get_option('gobject-cast-checks')
83 if cast_checks.disabled() or (cast_checks.auto() and not gst_version_is_dev)
84 message('Disabling GLib cast checks')
85 add_project_arguments('-DG_DISABLE_CAST_CHECKS', language: 'c')
88 glib_asserts = get_option('glib-asserts')
89 if glib_asserts.disabled() or (glib_asserts.auto() and not gst_version_is_dev)
90 message('Disabling GLib asserts')
91 add_project_arguments('-DG_DISABLE_ASSERT', language: 'c')
94 glib_checks = get_option('glib-checks')
95 if glib_checks.disabled() or (glib_checks.auto() and not gst_version_is_dev)
96 message('Disabling GLib checks')
97 add_project_arguments('-DG_DISABLE_CHECKS', language: 'c')
100 cdata = configuration_data()
103 ['HAVE_DLFCN_H', 'dlfcn.h'],
104 ['HAVE_FCNTL_H', 'fcntl.h'],
105 ['HAVE_INTTYPES_H', 'inttypes.h'],
106 ['HAVE_MEMORY_H', 'memory.h'],
107 ['HAVE_PROCESS_H', 'process.h'],
108 ['HAVE_STDINT_H', 'stdint.h'],
109 ['HAVE_STDLIB_H', 'stdlib.h'],
110 ['HAVE_STRINGS_H', 'strings.h'],
111 ['HAVE_STRING_H', 'string.h'],
112 ['HAVE_SYS_IOCTL_H', 'sys/ioctl.h'],
113 ['HAVE_SYS_PARAM_H', 'sys/param.h'],
114 ['HAVE_SYS_SOCKET_H', 'sys/socket.h'],
115 ['HAVE_SYS_STAT_H', 'sys/stat.h'],
116 ['HAVE_SYS_TIME_H', 'sys/time.h'],
117 ['HAVE_SYS_TYPES_H', 'sys/types.h'],
118 ['HAVE_UNISTD_H', 'unistd.h'],
121 foreach h : check_headers
122 if cc.has_header(h.get(1))
123 cdata.set(h.get(0), 1)
128 ['HAVE_ASINH', 'asinh', '#include<math.h>'],
129 ['HAVE_CLOCK_GETTIME', 'clock_gettime', '#include<time.h>'],
130 ['HAVE_COSH', 'cosh', '#include<math.h>'],
131 # check token HAVE_CPU_ALPHA
132 # check token HAVE_CPU_ARM
133 # check token HAVE_CPU_CRIS
134 # check token HAVE_CPU_CRISV32
135 # check token HAVE_CPU_HPPA
136 # check token HAVE_CPU_I386
137 # check token HAVE_CPU_IA64
138 # check token HAVE_CPU_M68K
139 # check token HAVE_CPU_MIPS
140 # check token HAVE_CPU_PPC
141 # check token HAVE_CPU_PPC64
142 # check token HAVE_CPU_S390
143 # check token HAVE_CPU_SPARC
144 # check token HAVE_CPU_X86_64
145 ['HAVE_DCGETTEXT', 'dcgettext', '#include<libintl.h>'],
146 # check token HAVE_DIRECTSOUND
147 # check token HAVE_EXPERIMENTAL
148 # check token HAVE_EXTERNAL
149 # check token HAVE_FPCLASS
150 # check token HAVE_GCC_ASM
151 ['HAVE_GETPAGESIZE', 'getpagesize', '#include<unistd.h>'],
152 # check token HAVE_GETTEXT
153 # check token HAVE_GST_V4L2
154 ['HAVE_ISINF', 'isinf', '#include<math.h>'],
155 # check token HAVE_LIBV4L2
156 ['HAVE_MMAP', 'mmap', '#include<sys/mman.h>'],
157 ['HAVE_MMAP64', 'mmap64', '#include<sys/mman.h>'],
158 # check token HAVE_OSX_AUDIO
159 # check token HAVE_OSX_VIDEO
160 # check token HAVE_RDTSC
161 ['HAVE_SINH', 'sinh', '#include<math.h>'],
162 # check token HAVE_WAVEFORM
163 ['HAVE_GMTIME_R', 'gmtime_r', '#include<time.h>'],
166 libm = cc.find_library('m', required : false)
168 foreach f : check_functions
169 if cc.has_function(f.get(1), prefix : f.get(2), dependencies : libm)
170 cdata.set(f.get(0), 1)
174 cdata.set('HAVE_IOS', host_system == 'ios')
176 cdata.set('SIZEOF_CHAR', cc.sizeof('char'))
177 cdata.set('SIZEOF_INT', cc.sizeof('int'))
178 cdata.set('SIZEOF_LONG', cc.sizeof('long'))
179 cdata.set('SIZEOF_SHORT', cc.sizeof('short'))
180 cdata.set('SIZEOF_VOIDP', cc.sizeof('void*'))
181 cdata.set('SIZEOF_OFF_T', cc.sizeof('off_t'))
184 # FIXME: check if this is correct
185 cdata.set('HAVE_CPU_X86_64', host_machine.cpu() == 'amd64')
186 cdata.set('HAVE_GCC_ASM', cc.get_id() != 'msvc')
187 cdata.set_quoted('VERSION', gst_version)
188 cdata.set_quoted('PACKAGE_VERSION', gst_version)
189 cdata.set_quoted('GST_LICENSE', 'LGPL')
190 cdata.set_quoted('PACKAGE', 'gst-plugins-good')
191 cdata.set_quoted('GETTEXT_PACKAGE', 'gst-plugins-good-1.0')
192 cdata.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
195 '-Wmissing-declarations',
199 '-Wmissing-include-dirs',
206 '-Wmissing-prototypes',
207 '-Wdeclaration-after-statement',
208 '-Wold-style-definition',
209 '-Waggregate-return',
213 cxx = meson.get_compiler('cpp')
216 foreach extra_arg : warning_flags
217 if cc.has_argument (extra_arg)
218 add_project_arguments([extra_arg], language: 'c')
220 if have_cxx and cxx.has_argument (extra_arg)
221 add_project_arguments([extra_arg], language: 'cpp')
225 foreach extra_arg : warning_c_flags
226 if cc.has_argument (extra_arg)
227 add_project_arguments([extra_arg], language: 'c')
231 # GStreamer package name and origin url
232 gst_package_name = get_option('package-name')
233 if gst_package_name == ''
234 if gst_version_nano == 0
235 gst_package_name = 'GStreamer Good Plug-ins source release'
236 elif gst_version_nano == 1
237 gst_package_name = 'GStreamer Good Plug-ins git'
239 gst_package_name = 'GStreamer Good Plug-ins prerelease'
242 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
243 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
246 gst_dep = dependency('gstreamer-1.0', version : gst_req,
247 fallback : ['gstreamer', 'gst_dep'])
248 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
249 fallback : ['gstreamer', 'gst_base_dep'])
250 gstnet_dep = dependency('gstreamer-net-1.0', version : gst_req,
251 fallback : ['gstreamer', 'gst_net_dep'])
252 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
253 fallback : ['gstreamer', 'gst_controller_dep'])
254 gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
255 required : get_option('tests'),
256 fallback : ['gstreamer', 'gst_check_dep'])
257 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
258 fallback : ['gst-plugins-base', 'pbutils_dep'])
259 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
260 fallback : ['gst-plugins-base', 'allocators_dep'])
261 gstapp_dep = dependency('gstreamer-app-1.0', version : gst_req,
262 fallback : ['gst-plugins-base', 'app_dep'])
263 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
264 fallback : ['gst-plugins-base', 'audio_dep'])
265 gstfft_dep = dependency('gstreamer-fft-1.0', version : gst_req,
266 fallback : ['gst-plugins-base', 'fft_dep'])
267 gstriff_dep = dependency('gstreamer-riff-1.0', version : gst_req,
268 fallback : ['gst-plugins-base', 'riff_dep'])
269 gstrtp_dep = dependency('gstreamer-rtp-1.0', version : gst_req,
270 fallback : ['gst-plugins-base', 'rtp_dep'])
271 gstrtsp_dep = dependency('gstreamer-rtsp-1.0', version : gst_req,
272 fallback : ['gst-plugins-base', 'rtsp_dep'])
273 gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
274 fallback : ['gst-plugins-base', 'sdp_dep'])
275 gsttag_dep = dependency('gstreamer-tag-1.0', version : gst_req,
276 fallback : ['gst-plugins-base', 'tag_dep'])
277 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
278 fallback : ['gst-plugins-base', 'video_dep'])
282 gstgl_dep = dependency('gstreamer-gl-1.0', version : gst_req,
283 fallback : ['gst-plugins-base', 'gstgl_dep'], required: false)
284 gstglproto_dep = dependency('', required : false)
285 gstglx11_dep = dependency('', required : false)
286 gstglwayland_dep = dependency('', required : false)
287 gstglegl_dep = dependency('', required : false)
289 have_gstgl = gstgl_dep.found()
292 if gstgl_dep.type_name() == 'pkgconfig'
293 gst_gl_apis = gstgl_dep.get_pkgconfig_variable('gl_apis').split()
294 gst_gl_winsys = gstgl_dep.get_pkgconfig_variable('gl_winsys').split()
295 gst_gl_platforms = gstgl_dep.get_pkgconfig_variable('gl_platforms').split()
297 gstbase = subproject('gst-plugins-base')
298 gst_gl_apis = gstbase.get_variable('enabled_gl_apis')
299 gst_gl_winsys = gstbase.get_variable('enabled_gl_winsys')
300 gst_gl_platforms = gstbase.get_variable('enabled_gl_platforms')
303 message('GStreamer OpenGL window systems: @0@'.format(' '.join(gst_gl_winsys)))
304 message('GStreamer OpenGL platforms: @0@'.format(' '.join(gst_gl_platforms)))
305 message('GStreamer OpenGL apis: @0@'.format(' '.join(gst_gl_apis)))
307 foreach ws : ['x11', 'wayland', 'android', 'cocoa', 'eagl', 'win32', 'dispmanx', 'viv_fb']
308 set_variable('gst_gl_have_window_@0@'.format(ws), gst_gl_winsys.contains(ws))
311 foreach p : ['glx', 'egl', 'cgl', 'eagl', 'wgl']
312 set_variable('gst_gl_have_platform_@0@'.format(p), gst_gl_platforms.contains(p))
315 foreach api : ['gl', 'gles2']
316 set_variable('gst_gl_have_api_@0@'.format(api), gst_gl_apis.contains(api))
319 gstglproto_dep = dependency('gstreamer-gl-prototypes-1.0', version : gst_req,
320 fallback : ['gst-plugins-base', 'gstglproto_dep'], required: true)
321 # Behind specific checks because meson fails at optional dependencies with a
322 # fallback to the same subproject. On the first failure, meson will never
323 # check the system again even if the fallback never existed.
324 # Last checked with meson 0.54.3
325 if gst_gl_have_window_x11
326 gstglx11_dep = dependency('gstreamer-gl-x11-1.0', version : gst_req,
327 fallback : ['gst-plugins-base', 'gstglx11_dep'], required: true)
329 if gst_gl_have_window_wayland
330 gstglwayland_dep = dependency('gstreamer-gl-wayland-1.0', version : gst_req,
331 fallback : ['gst-plugins-base', 'gstglwayland_dep'], required: true)
333 if gst_gl_have_platform_egl
334 gstglegl_dep = dependency('gstreamer-gl-egl-1.0', version : gst_req,
335 fallback : ['gst-plugins-base', 'gstglegl_dep'], required: true)
339 zlib_dep = dependency('zlib', required : false)
340 if not zlib_dep.found()
341 zlib_dep = cc.find_library('z', required : false)
342 if not zlib_dep.found() or not cc.has_header('zlib.h')
343 zlib_dep = subproject('zlib').get_variable('zlib_dep')
346 cdata.set('HAVE_ZLIB', true)
348 glib_deps = [dependency('glib-2.0', version : glib_req, fallback: ['glib', 'libglib_dep']),
349 dependency('gobject-2.0', fallback: ['glib', 'libgobject_dep'])]
350 gio_dep = dependency('gio-2.0', fallback: ['glib', 'libgio_dep'])
352 gst_plugins_good_args = ['-DHAVE_CONFIG_H']
353 configinc = include_directories('.')
354 libsinc = include_directories('gst-libs')
359 # Used by various libraries/elements that use Orc code
360 orc_dep = dependency('orc-0.4', version : orc_req, required : get_option('orc'),
361 fallback : ['orc', 'orc_dep'])
362 orcc = find_program('orcc', required : get_option('orc'))
363 if orc_dep.found() and orcc.found()
365 orcc_args = [orcc, '--include', 'glib.h']
366 cdata.set('HAVE_ORC', 1)
368 message('Orc Compiler not found, will use backup C code')
369 cdata.set('DISABLE_ORC', 1)
373 # FIXME: nasm path needs testing on non-Linux, esp. Windows
374 host_cpu = host_machine.cpu_family()
375 if host_cpu == 'x86_64'
376 if cc.get_define('__ILP32__') == '1'
377 message('Nasm disabled on x32')
379 asm_option = get_option('asm')
380 nasm = find_program('nasm', native: true, required: asm_option)
382 # We can't use the version: kwarg for find_program because old versions
383 # of nasm don't support --version
384 ret = run_command(nasm, '-v')
385 if ret.returncode() == 0
386 nasm_version = ret.stdout().strip().split()[2]
388 if nasm_version.version_compare(nasm_req)
389 message('nasm found on x86-64')
390 cdata.set('HAVE_NASM', 1)
393 if asm_option.enabled()
394 error('asm option is enabled, and nasm @0@ was found, but @1@ is required'.format(nasm_version, nasm_req))
396 message('nasm @0@ was found, but @1@ is required'.format(nasm_version, nasm_req))
399 if asm_option.enabled()
400 error('asm option is enabled, but nasm is not usable: @0@\n@1@'.format(ret.stdout(), ret.stderr()))
402 message('nasm was found, but it\'s not usable')
404 # Unset nasm to not be 'found'
412 # Disable compiler warnings for unused variables and args if gst debug system is disabled
413 if gst_dep.type_name() == 'internal'
414 gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
416 # We can't check that in the case of subprojects as we won't
417 # be able to build against an internal dependency (which is not built yet)
418 gst_debug_disabled = cc.has_header_symbol('gst/gstconfig.h', 'GST_DISABLE_GST_DEBUG', dependencies: gst_dep)
421 if gst_debug_disabled
422 message('GStreamer debug system is disabled')
423 if cc.has_argument('-Wno-unused')
424 add_project_arguments('-Wno-unused', language: 'c')
426 if have_cxx and cxx.has_argument ('-Wno-unused')
427 add_project_arguments('-Wno-unused', language: 'cpp')
430 message('GStreamer debug system is enabled')
433 presetdir = join_paths(get_option('datadir'), 'gstreamer-' + api_version, 'presets')
435 python3 = import('python').find_installation()
436 pkgconfig = import('pkgconfig')
437 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
438 if get_option('default_library') == 'shared'
439 # If we don't build static plugins there is no need to generate pc files
440 plugins_pkgconfig_install_dir = disabler()
449 if have_orcc and orc_targets.length() > 0
450 update_orc_dist_files = find_program('scripts/update-orc-dist-files.py')
452 orc_update_targets = []
453 foreach t : orc_targets
454 orc_name = t.get('name')
455 orc_file = t.get('orc-source')
456 header = t.get('header')
457 source = t.get('source')
458 # alias_target() only works with build targets, so can't use run_target() here
459 orc_update_targets += [
460 custom_target('update-orc-@0@'.format(orc_name),
461 input: [header, source],
462 command: [update_orc_dist_files, orc_file, header, source],
463 output: ['@0@-dist.c'.format(orc_name)]) # not entirely true
467 if meson.version().version_compare('>= 0.52')
468 update_orc_dist_target = alias_target('update-orc-dist', orc_update_targets)
472 # xgettext is optional (on Windows for instance)
473 if find_program('xgettext', required : get_option('nls')).found()
474 cdata.set('ENABLE_NLS', 1)
481 if gst_version_nano == 0
482 extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
483 run_result = run_command(extract_release_date, gst_version, files('gst-plugins-good.doap'))
484 if run_result.returncode() == 0
485 release_date = run_result.stdout().strip()
486 cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
487 message('Package release date: ' + release_date)
489 # Error out if our release can't be found in the .doap file
490 error(run_result.stderr())
494 if gio_dep.version().version_compare('< 2.67.4')
495 cdata.set('g_memdup2(ptr,sz)', '(G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(),NULL)')
498 configure_file(output : 'config.h', configuration : cdata)
500 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')
502 if meson.version().version_compare('>= 0.54')
504 foreach plugin: plugins
505 # FIXME: Use str.subtring() when we can depend on Meson 0.56
506 split = plugin.name().split('gst')
507 if split.length() == 2
508 plugin_names += [split[1]]
510 warning('Need substring API in meson >= 0.56 to properly parse plugin name: ' + plugin.name())
511 plugin_names += [plugin.name()]
514 summary({'Plugins':plugin_names}, list_sep: ', ')