1 project('gst-libav', 'c',
3 meson_version : '>= 0.62',
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
21 libavfilter_dep = dependency('libavfilter', version: '>= 7.16.100',
22 fallback: ['FFmpeg', 'libavfilter_dep'])
23 libavformat_dep = dependency('libavformat', version: '>= 58.12.100',
24 fallback: ['FFmpeg', 'libavformat_dep'])
25 libavcodec_dep = dependency('libavcodec', version: '>= 58.18.100',
26 fallback: ['FFmpeg', 'libavcodec_dep'])
27 libavutil_dep = dependency('libavutil', version: '>= 56.14.100',
28 fallback: ['FFmpeg', 'libavutil_dep'])
30 libav_deps = [libavfilter_dep, libavformat_dep, libavcodec_dep, libavutil_dep]
32 cc = meson.get_compiler('c')
33 static_build = get_option('default_library') == 'static'
35 check_ffmpeg_src = '''#include <libavcodec/avcodec.h>
36 #if LIBAVCODEC_VERSION_MICRO >= 100
37 /* FFmpeg uses 100+ as its micro version */
39 #error libav provider should be FFmpeg
42 libav_deps_type_name = ''
44 foreach dep: libav_deps
45 if libav_deps_type_name != '' and dep.type_name() != libav_deps_type_name
46 error('Libav deps must be either all internal or all external')
48 libav_deps_type_name = dep.type_name()
51 if dep.type_name() != 'internal'
52 if not cc.compiles(check_ffmpeg_src, dependencies : libav_deps, name : 'libav is provided by FFmpeg')
53 error('Uncompatible libavcodec found')
57 cdata = configuration_data()
58 cdata.set('LIBAV_SOURCE', '"system install"')
59 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
60 cdata.set('PACKAGE', '"gst-libav"')
62 # GStreamer package name and origin url
63 gst_package_name = get_option('package-name')
64 if gst_package_name == ''
65 if gst_version_nano == 0
66 gst_package_name = 'GStreamer FFMPEG Plug-ins source release'
67 elif gst_version_nano == 1
68 gst_package_name = 'GStreamer FFMPEG Plug-ins git'
70 gst_package_name = 'GStreamer FFMPEG Plug-ins prerelease'
73 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
74 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
77 check_headers = [['unistd.h', 'HAVE_UNISTD_H']]
79 foreach h : check_headers
80 if cc.has_header(h.get(0))
81 cdata.set(h.get(1), 1)
85 if gst_version_is_stable
86 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
88 gst_req = '>= ' + gst_version
91 gst_dep = dependency('gstreamer-1.0', version : gst_req,
92 fallback : ['gstreamer', 'gst_dep'])
93 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
94 fallback : ['gstreamer', 'gst_base_dep'])
95 gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
96 required : get_option('tests'),
97 fallback : ['gstreamer', 'gst_check_dep'])
99 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
100 fallback : ['gst-plugins-base', 'video_dep'])
101 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
102 fallback : ['gst-plugins-base', 'audio_dep'])
103 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
104 fallback : ['gst-plugins-base', 'pbutils_dep'])
105 libm = cc.find_library('m', required : false)
107 gst_libav_args = ['-DHAVE_CONFIG_H']
108 if cc.get_id() == 'msvc'
110 # Ignore several spurious warnings for things gstreamer does very commonly
111 # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
112 # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
113 # NOTE: Only add warnings here if you are sure they're spurious
114 '/wd4018', # implicit signed/unsigned conversion
115 '/wd4146', # unary minus on unsigned (beware INT_MIN)
116 '/wd4244', # lossy type conversion (e.g. double -> int)
117 '/wd4305', # truncating type conversion (e.g. double -> float)
118 cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
121 if gst_version_is_dev
122 # Enable some warnings on MSVC to match GCC/Clang behaviour
123 msvc_args += cc.get_supported_arguments([
124 '/we4002', # too many actual parameters for macro 'identifier'
125 '/we4003', # not enough actual parameters for macro 'identifier'
126 '/we4013', # 'function' undefined; assuming extern returning int
127 '/we4020', # 'function' : too many actual parameters
128 '/we4027', # function declared without formal parameter list
129 '/we4029', # declared formal parameter list different from definition
130 '/we4033', # 'function' must return a value
131 '/we4045', # 'array' : array bounds overflow
132 '/we4047', # 'operator' : 'identifier1' differs in levels of indirection from 'identifier2'
133 '/we4053', # one void operand for '?:'
134 '/we4062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled
135 '/we4098', # 'function' : void function returning a value
136 '/we4101', # 'identifier' : unreferenced local variable
137 '/we4189', # 'identifier' : local variable is initialized but not referenced
140 add_project_arguments(msvc_args, language: ['c', 'cpp'])
143 # glib doesn't support unloading, which means that unloading and reloading
144 # any library that registers static types will fail
145 if cc.has_link_argument('-Wl,-z,nodelete')
146 add_project_link_arguments('-Wl,-z,nodelete', language: 'c')
150 if cc.has_argument('-fvisibility=hidden')
151 add_project_arguments('-fvisibility=hidden', language: 'c')
154 # Don't export any symbols from static ffmpeg libraries
155 if cc.has_link_argument('-Wl,--exclude-libs=ALL')
156 add_project_link_arguments('-Wl,--exclude-libs=ALL', language: 'c')
159 # Disable strict aliasing
160 if cc.has_argument('-fno-strict-aliasing')
161 add_project_arguments('-fno-strict-aliasing', language: 'c')
164 if gst_dep.type_name() == 'internal'
165 gst_proj = subproject('gstreamer')
167 if not gst_proj.get_variable('gst_debug')
168 message('GStreamer debug system is disabled')
169 add_project_arguments('-Wno-unused', language: 'c')
171 message('GStreamer debug system is enabled')
174 # We can't check that in the case of subprojects as we won't
175 # be able to build against an internal dependency (which is not built yet)
176 if not cc.compiles('''
177 #include <gst/gstconfig.h>
178 #ifdef GST_DISABLE_GST_DEBUG
179 #error "debugging disabled, make compiler fail"
180 #endif''' , dependencies: gst_dep)
181 message('GStreamer debug system is disabled')
182 add_project_arguments('-Wno-unused', language: 'c')
184 message('GStreamer debug system is enabled')
189 '-Wmissing-declarations',
190 '-Wmissing-prototypes',
191 '-Wold-style-definition',
196 '-Wformat-nonliteral',
199 '-Wmissing-include-dirs',
202 '-Waggregate-return',
207 foreach extra_arg : warning_flags
208 if cc.has_argument (extra_arg)
209 add_project_arguments([extra_arg], language: 'c')
213 configinc = include_directories('.')
214 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
216 pkgconfig = import('pkgconfig')
217 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
218 if get_option('default_library') == 'shared'
219 # If we don't build static plugins there is no need to generate pc files
220 plugins_pkgconfig_install_dir = disabler()
229 if gst_version_nano == 0
230 extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
231 run_result = run_command(extract_release_date, gst_version, files('gst-libav.doap'), check: true)
232 release_date = run_result.stdout().strip()
233 cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
234 message('Package release date: ' + release_date)
237 configure_file(output: 'config.h', configuration: cdata)
240 foreach plugin: plugins
241 pkgconfig.generate(plugin, install_dir: plugins_pkgconfig_install_dir)
242 dep = declare_dependency(link_with: plugin, variables: {'full_path': plugin.full_path()})
243 meson.override_dependency(plugin.name(), dep)