meson: Ignore spurious issues when building with msvc
[platform/upstream/gstreamer.git] / meson.build
1 project('gst-libav', 'c', 'cpp',
2   version : '1.11.0.1',
3   meson_version : '>= 0.36.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]
10 gst_version_minor = version_arr[1]
11
12 libavfilter_dep = dependency('libavfilter', version: '>= 6.47.100')
13 libavformat_dep = dependency('libavformat', version: '>= 57.41.100')
14 libavcodec_dep = dependency('libavcodec', version: '>= 57.48.101')
15 libavutil_dep = dependency('libavutil', version: '>= 55.28.100')
16
17 libav_deps = [libavfilter_dep, libavformat_dep, libavcodec_dep, libavutil_dep]
18
19 cc = meson.get_compiler('c')
20
21 check_ffmpeg_src = '''#include <libavcodec/avcodec.h>
22 #if LIBAVCODEC_VERSION_MICRO >= 100
23 /* FFmpeg uses 100+ as its micro version */
24 #else
25 #error libav provider should be FFmpeg
26 #endif'''
27
28 if not cc.compiles(check_ffmpeg_src, dependencies : libav_deps, name : 'libav is provided by FFmpeg')
29     error('Uncompatible libavcodec found')
30 endif
31
32 cdata = configuration_data()
33 cdata.set('LIBAV_SOURCE', '"system install"')
34 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
35 cdata.set('PACKAGE', '"gst-libav"')
36 check_headers = [['unistd.h', 'HAVE_UNISTD_H']]
37
38 foreach h : check_headers
39   if cc.has_header(h.get(0))
40     cdata.set(h.get(1), 1)
41   endif
42 endforeach
43
44 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
45 gst_dep = dependency('gstreamer-1.0', version : gst_req,
46   fallback : ['gstreamer', 'gst_dep'])
47 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
48   fallback : ['gstreamer', 'gst_base_dep'])
49
50 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
51     fallback : ['gst-plugins-base', 'video_dep'])
52 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
53     fallback : ['gst-plugins-base', 'audio_dep'])
54 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
55     fallback : ['gst-plugins-base', 'pbutils_dep'])
56 libm = cc.find_library('m', required : false)
57
58 configure_file(output : 'config.h', configuration : cdata)
59
60 gst_libav_args = ['-DHAVE_CONFIG_H']
61 if cc.get_id() != 'msvc'
62   gst_libav_args += ['-Wno-deprecated-declarations']
63 else
64   # Ignore several spurious warnings for things gstreamer does very commonly
65   # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
66   # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
67   # NOTE: Only add warnings here if you are sure they're spurious
68   add_project_arguments(
69       '/wd4018', # implicit signed/unsigned conversion
70       '/wd4146', # unary minus on unsigned (beware INT_MIN)
71       '/wd4244', # lossy type conversion (e.g. double -> int)
72       '/wd4305', # truncating type conversion (e.g. double -> float)
73       language : 'c')
74 endif
75
76 configinc = include_directories('.')
77 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
78 subdir('ext/libav/')
79
80 python3 = find_program('python3')
81 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')