Update ffmpeg version requirements
[platform/upstream/gst-libav.git] / meson.build
1 project('gst-libav', 'c', 'cpp',
2   version : '1.15.0.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 libavformat_dep = dependency('libavformat', version: '>= 58.12.100')
20 libavcodec_dep = dependency('libavcodec', version: '>= 58.18.100')
21 libavutil_dep = dependency('libavutil', version: '>= 56.14.100')
22
23 libav_deps = [libavfilter_dep, libavformat_dep, libavcodec_dep, libavutil_dep]
24
25 cc = meson.get_compiler('c')
26
27 check_ffmpeg_src = '''#include <libavcodec/avcodec.h>
28 #if LIBAVCODEC_VERSION_MICRO >= 100
29 /* FFmpeg uses 100+ as its micro version */
30 #else
31 #error libav provider should be FFmpeg
32 #endif'''
33
34 if not cc.compiles(check_ffmpeg_src, dependencies : libav_deps, name : 'libav is provided by FFmpeg')
35     error('Uncompatible libavcodec found')
36 endif
37
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"')
42
43 # GStreamer package name and origin url
44 gst_package_name = get_option('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'
50   else
51     gst_package_name = 'GStreamer FFMPEG Plug-ins prerelease'
52   endif
53 endif
54 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
55 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
56
57
58 check_headers = [['unistd.h', 'HAVE_UNISTD_H']]
59
60 foreach h : check_headers
61   if cc.has_header(h.get(0))
62     cdata.set(h.get(1), 1)
63   endif
64 endforeach
65
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'])
71
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)
79
80 configure_file(output : 'config.h', configuration : cdata)
81
82 gst_libav_args = ['-DHAVE_CONFIG_H']
83 if cc.get_id() == 'msvc'
84   # Ignore several spurious warnings for things gstreamer does very commonly
85   # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
86   # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
87   # NOTE: Only add warnings here if you are sure they're spurious
88   add_project_arguments(
89       '/wd4018', # implicit signed/unsigned conversion
90       '/wd4146', # unary minus on unsigned (beware INT_MIN)
91       '/wd4244', # lossy type conversion (e.g. double -> int)
92       '/wd4305', # truncating type conversion (e.g. double -> float)
93       language : 'c')
94 endif
95
96 # Symbol visibility
97 if cc.has_argument('-fvisibility=hidden')
98   add_project_arguments('-fvisibility=hidden', language: 'c')
99 endif
100
101 # Disable strict aliasing
102 if cc.has_argument('-fno-strict-aliasing')
103   add_project_arguments('-fno-strict-aliasing', language: 'c')
104 endif
105
106 if gst_dep.type_name() == 'internal'
107     gst_proj = subproject('gstreamer')
108
109     if not gst_proj.get_variable('gst_debug')
110         message('GStreamer debug system is disabled')
111         add_project_arguments('-Wno-unused', language: 'c')
112     else
113         message('GStreamer debug system is enabled')
114     endif
115 else
116     # We can't check that in the case of subprojects as we won't
117     # be able to build against an internal dependency (which is not built yet)
118     if not cc.compiles('''
119 #include <gst/gstconfig.h>
120 #ifdef GST_DISABLE_GST_DEBUG
121 #error "debugging disabled, make compiler fail"
122 #endif''' , dependencies: gst_dep)
123         message('GStreamer debug system is disabled')
124         add_project_arguments('-Wno-unused', language: 'c')
125     else
126         message('GStreamer debug system is enabled')
127     endif
128 endif
129
130 warning_flags = [
131   '-Wmissing-declarations',
132   '-Wmissing-prototypes',
133   '-Wold-style-definition',
134   '-Wredundant-decls',
135   '-Wundef',
136   '-Wwrite-strings',
137   '-Wformat',
138   '-Wformat-nonliteral',
139   '-Wformat-security',
140   '-Winit-self',
141   '-Wmissing-include-dirs',
142   '-Waddress',
143   '-Wno-multichar',
144   '-Waggregate-return',
145   '-Wdeclaration-after-statement',
146   '-Wvla',
147   '-Wpointer-arith',
148 ]
149
150 foreach extra_arg : warning_flags
151   if cc.has_argument (extra_arg)
152     add_project_arguments([extra_arg], language: 'c')
153   endif
154 endforeach
155
156 configinc = include_directories('.')
157 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
158 subdir('ext/libav/')
159
160 python3 = import('python3').find_python()
161 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')