1 project('gst-libav', 'c', 'cpp',
3 meson_version : '>= 0.36.0',
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()
18 libavfilter_dep = dependency('libavfilter', version: '>= 6.47.100')
19 libavformat_dep = dependency('libavformat', version: '>= 57.41.100')
20 libavcodec_dep = dependency('libavcodec', version: '>= 57.48.101')
21 libavutil_dep = dependency('libavutil', version: '>= 55.28.100')
23 libav_deps = [libavfilter_dep, libavformat_dep, libavcodec_dep, libavutil_dep]
25 cc = meson.get_compiler('c')
27 check_ffmpeg_src = '''#include <libavcodec/avcodec.h>
28 #if LIBAVCODEC_VERSION_MICRO >= 100
29 /* FFmpeg uses 100+ as its micro version */
31 #error libav provider should be FFmpeg
34 if not cc.compiles(check_ffmpeg_src, dependencies : libav_deps, name : 'libav is provided by FFmpeg')
35 error('Uncompatible libavcodec found')
38 cdata = configuration_data()
39 cdata.set('LIBAV_SOURCE', '"system install"')
40 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
41 cdata.set('PACKAGE', '"gst-libav"')
43 # GStreamer package name and origin url
44 gst_package_name = get_option('with-package-name')
45 if gst_package_name == ''
46 if gst_version_nano == 0
47 gst_package_name = 'GStreamer FFMPEG Plug-ins source release'
48 elif gst_version_nano == 1
49 gst_package_name = 'GStreamer FFMPEG Plug-ins git'
51 gst_package_name = 'GStreamer FFMPEG Plug-ins prerelease'
54 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
55 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('with-package-origin'))
58 check_headers = [['unistd.h', 'HAVE_UNISTD_H']]
60 foreach h : check_headers
61 if cc.has_header(h.get(0))
62 cdata.set(h.get(1), 1)
66 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
67 gst_dep = dependency('gstreamer-1.0', version : gst_req,
68 fallback : ['gstreamer', 'gst_dep'])
69 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
70 fallback : ['gstreamer', 'gst_base_dep'])
72 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
73 fallback : ['gst-plugins-base', 'video_dep'])
74 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
75 fallback : ['gst-plugins-base', 'audio_dep'])
76 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
77 fallback : ['gst-plugins-base', 'pbutils_dep'])
78 libm = cc.find_library('m', required : false)
80 configure_file(output : 'config.h', configuration : cdata)
82 gst_libav_args = ['-DHAVE_CONFIG_H']
83 if cc.get_id() != 'msvc'
84 gst_libav_args += ['-Wno-deprecated-declarations']
86 # Ignore several spurious warnings for things gstreamer does very commonly
87 # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
88 # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
89 # NOTE: Only add warnings here if you are sure they're spurious
90 add_project_arguments(
91 '/wd4018', # implicit signed/unsigned conversion
92 '/wd4146', # unary minus on unsigned (beware INT_MIN)
93 '/wd4244', # lossy type conversion (e.g. double -> int)
94 '/wd4305', # truncating type conversion (e.g. double -> float)
99 if cc.has_argument('-fvisibility=hidden')
100 add_project_arguments('-fvisibility=hidden', language: 'c')
103 # Disable strict aliasing
104 if cc.has_argument('-fno-strict-aliasing')
105 add_project_arguments('-fno-strict-aliasing', language: 'c')
108 if gst_dep.type_name() == 'internal'
109 gst_proj = subproject('gstreamer')
111 if gst_proj.get_variable('disable_gst_debug')
112 message('GStreamer debug system is disabled')
113 add_project_arguments('-Wno-unused', language: 'c')
115 message('GStreamer debug system is enabled')
118 # We can't check that in the case of subprojects as we won't
119 # be able to build against an internal dependency (which is not built yet)
120 if not cc.compiles('''
121 #include <gst/gstconfig.h>
122 #ifdef GST_DISABLE_GST_DEBUG
123 #error "debugging disabled, make compiler fail"
124 #endif''' , dependencies: gst_dep)
125 message('GStreamer debug system is disabled')
126 add_project_arguments('-Wno-unused', language: 'c')
128 message('GStreamer debug system is enabled')
133 '-Wmissing-declarations',
134 '-Wmissing-prototypes',
135 '-Wold-style-definition',
140 '-Wformat-nonliteral',
143 '-Wmissing-include-dirs',
146 '-Waggregate-return',
147 '-Wdeclaration-after-statement',
152 foreach extra_arg : warning_flags
153 if cc.has_argument (extra_arg)
154 add_project_arguments([extra_arg], language: 'c')
158 configinc = include_directories('.')
159 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
162 python3 = import('python3').find_python()
163 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')