avviddec: do not add 708 caption meta if already exists
[platform/upstream/gst-libav.git] / meson.build
1 project('gst-libav', 'c', 'cpp',
2   version : '1.15.2.1',
3   meson_version : '>= 0.46.0',
4   default_options : [ 'warning_level=1',
5                       'buildtype=debugoptimized' ])
6
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()
14 else
15   gst_version_nano = 0
16 endif
17
18 libavfilter_dep = dependency('libavfilter', version: '>= 7.16.100',
19   fallback: ['FFmpeg', 'libavfilter_dep'])
20 libavformat_dep = dependency('libavformat', version: '>= 58.12.100',
21   fallback: ['FFmpeg', 'libavformat_dep'])
22 libavcodec_dep = dependency('libavcodec', version: '>= 58.18.100',
23   fallback: ['FFmpeg', 'libavcodec_dep'])
24 libavutil_dep = dependency('libavutil', version: '>= 56.14.100',
25   fallback: ['FFmpeg', 'libavutil_dep'])
26
27 libav_deps = [libavfilter_dep, libavformat_dep, libavcodec_dep, libavutil_dep]
28
29 cc = meson.get_compiler('c')
30
31 check_ffmpeg_src = '''#include <libavcodec/avcodec.h>
32 #if LIBAVCODEC_VERSION_MICRO >= 100
33 /* FFmpeg uses 100+ as its micro version */
34 #else
35 #error libav provider should be FFmpeg
36 #endif'''
37
38 libav_deps_type_name = ''
39
40 foreach dep: libav_deps
41   if libav_deps_type_name != '' and dep.type_name() != libav_deps_type_name
42     error('Libav deps must be either all internal or all external')
43   endif
44   libav_deps_type_name = dep.type_name()
45 endforeach
46
47 if dep.type_name() != 'internal'
48   if not cc.compiles(check_ffmpeg_src, dependencies : libav_deps, name : 'libav is provided by FFmpeg')
49     error('Uncompatible libavcodec found')
50   endif
51 endif
52
53 cdata = configuration_data()
54 cdata.set('LIBAV_SOURCE', '"system install"')
55 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
56 cdata.set('PACKAGE', '"gst-libav"')
57
58 # GStreamer package name and origin url
59 gst_package_name = get_option('package-name')
60 if gst_package_name == ''
61   if gst_version_nano == 0
62     gst_package_name = 'GStreamer FFMPEG Plug-ins source release'
63   elif gst_version_nano == 1
64     gst_package_name = 'GStreamer FFMPEG Plug-ins git'
65   else
66     gst_package_name = 'GStreamer FFMPEG Plug-ins prerelease'
67   endif
68 endif
69 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
70 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
71
72
73 check_headers = [['unistd.h', 'HAVE_UNISTD_H']]
74
75 foreach h : check_headers
76   if cc.has_header(h.get(0))
77     cdata.set(h.get(1), 1)
78   endif
79 endforeach
80
81 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
82 gst_dep = dependency('gstreamer-1.0', version : gst_req,
83   fallback : ['gstreamer', 'gst_dep'])
84 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
85   fallback : ['gstreamer', 'gst_base_dep'])
86
87 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
88     fallback : ['gst-plugins-base', 'video_dep'])
89 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
90     fallback : ['gst-plugins-base', 'audio_dep'])
91 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
92     fallback : ['gst-plugins-base', 'pbutils_dep'])
93 libm = cc.find_library('m', required : false)
94
95 configure_file(output : 'config.h', configuration : cdata)
96
97 gst_libav_args = ['-DHAVE_CONFIG_H']
98 if cc.get_id() == 'msvc'
99   # Ignore several spurious warnings for things gstreamer does very commonly
100   # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
101   # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
102   # NOTE: Only add warnings here if you are sure they're spurious
103   add_project_arguments(
104       '/wd4018', # implicit signed/unsigned conversion
105       '/wd4146', # unary minus on unsigned (beware INT_MIN)
106       '/wd4244', # lossy type conversion (e.g. double -> int)
107       '/wd4305', # truncating type conversion (e.g. double -> float)
108       language : 'c')
109 endif
110
111 # Symbol visibility
112 if cc.has_argument('-fvisibility=hidden')
113   add_project_arguments('-fvisibility=hidden', language: 'c')
114 endif
115
116 # Don't export any symbols from static ffmpeg libraries
117 if cc.has_link_argument('-Wl,--exclude-libs=ALL')
118   add_project_link_arguments('-Wl,--exclude-libs=ALL', language: 'c')
119 endif
120
121 # Disable strict aliasing
122 if cc.has_argument('-fno-strict-aliasing')
123   add_project_arguments('-fno-strict-aliasing', language: 'c')
124 endif
125
126 if gst_dep.type_name() == 'internal'
127     gst_proj = subproject('gstreamer')
128
129     if not gst_proj.get_variable('gst_debug')
130         message('GStreamer debug system is disabled')
131         add_project_arguments('-Wno-unused', language: 'c')
132     else
133         message('GStreamer debug system is enabled')
134     endif
135 else
136     # We can't check that in the case of subprojects as we won't
137     # be able to build against an internal dependency (which is not built yet)
138     if not cc.compiles('''
139 #include <gst/gstconfig.h>
140 #ifdef GST_DISABLE_GST_DEBUG
141 #error "debugging disabled, make compiler fail"
142 #endif''' , dependencies: gst_dep)
143         message('GStreamer debug system is disabled')
144         add_project_arguments('-Wno-unused', language: 'c')
145     else
146         message('GStreamer debug system is enabled')
147     endif
148 endif
149
150 warning_flags = [
151   '-Wmissing-declarations',
152   '-Wmissing-prototypes',
153   '-Wold-style-definition',
154   '-Wredundant-decls',
155   '-Wundef',
156   '-Wwrite-strings',
157   '-Wformat',
158   '-Wformat-nonliteral',
159   '-Wformat-security',
160   '-Winit-self',
161   '-Wmissing-include-dirs',
162   '-Waddress',
163   '-Wno-multichar',
164   '-Waggregate-return',
165   '-Wdeclaration-after-statement',
166   '-Wvla',
167   '-Wpointer-arith',
168 ]
169
170 foreach extra_arg : warning_flags
171   if cc.has_argument (extra_arg)
172     add_project_arguments([extra_arg], language: 'c')
173   endif
174 endforeach
175
176 configinc = include_directories('.')
177 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
178 pkgconfig = import('pkgconfig')
179 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
180 if get_option('default_library') == 'shared'
181   # If we don't build static plugins there is no need to generate pc files
182   plugins_pkgconfig_install_dir = disabler()
183 endif
184 subdir('ext/libav')
185
186 python3 = import('python').find_installation()
187 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')