meson: add_global_arguments -> add_project_arguments
[platform/upstream/gstreamer.git] / meson.build
1 project('gst-plugins-bad', '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 gst_version_micro = version_arr[2]
12 if version_arr.length() == 4
13   gst_version_nano = version_arr[3]
14 else
15   gst_version_nano = 0
16 endif
17
18 glib_req = '>= 2.40.0'
19 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
20
21 api_version = '1.0'
22 soversion = 0
23 # maintaining compatibility with the previous libtool versioning
24 # current = minor * 100 + micro
25 libversion = '@0@.@1@.0'.format(soversion, gst_version_minor.to_int() * 100 + gst_version_micro.to_int())
26
27 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
28
29 cc = meson.get_compiler('c')
30
31 if cc.get_id() == 'msvc'
32   # Ignore several spurious warnings for things gstreamer does very commonly
33   # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
34   # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
35   # NOTE: Only add warnings here if you are sure they're spurious
36   add_project_arguments(
37       '/wd4018', # implicit signed/unsigned conversion
38       '/wd4146', # unary minus on unsigned (beware INT_MIN)
39       '/wd4244', # lossy type conversion (e.g. double -> int)
40       '/wd4305', # truncating type conversion (e.g. double -> float)
41       language : 'c')
42   # Disable SAFESEH with MSVC for plugins and libs that use external deps that
43   # are built with MinGW
44   noseh_link_args = ['/SAFESEH:NO']
45 else
46   noseh_link_args = []
47 endif
48
49 cdata = configuration_data()
50 check_headers = [
51   ['HAVE_DLFCN_H', 'dlfcn.h'],
52   ['HAVE_FCNTL_H', 'fcntl.h'],
53   ['HAVE_HIGHGUI_H', 'highgui.h'],
54   ['HAVE_INTTYPES_H', 'inttypes.h'],
55   ['HAVE_MEMORY_H', 'memory.h'],
56   ['HAVE_MSACM_H', 'msacm.h'],
57   ['HAVE_NETINET_IN_H', 'netinet/in.h'],
58   ['HAVE_NETINET_IP_H', 'netinet/ip.h'],
59   ['HAVE_NETINET_TCP_H', 'netinet/tcp.h'],
60   ['HAVE_OPENCV2_HIGHGUI_HIGHGUI_C_H', 'opencv2/highgui/highgui_c.h'],
61   ['HAVE_PTHREAD_H', 'pthread.h'],
62   ['HAVE_STDINT_H', 'stdint.h'],
63   ['HAVE_STDLIB_H', 'stdlib.h'],
64   ['HAVE_STRINGS_H', 'strings.h'],
65   ['HAVE_STRING_H', 'string.h'],
66   ['HAVE_SYS_PARAM_H', 'sys/param.h'],
67   ['HAVE_SYS_SOCKET_H', 'sys/socket.h'],
68   ['HAVE_SYS_STAT_H', 'sys/stat.h'],
69   ['HAVE_SYS_TIME_H', 'sys/time.h'],
70   ['HAVE_SYS_TYPES_H', 'sys/types.h'],
71   ['HAVE_SYS_UTSNAME_H', 'sys/utsname.h'],
72   ['HAVE_UNISTD_H', 'unistd.h'],
73   ['HAVE_WINDOWS_H', 'windows.h'],
74   ['HAVE_WININET_H', 'wininet.h'],
75   ['HAVE_WINSOCK2_H', 'winsock2.h'],
76   ['HAVE_WS2TCPIP_H', 'ws2tcpip.h'],
77 ]
78
79 foreach h : check_headers
80   if cc.has_header(h.get(1))
81     cdata.set(h.get(0), 1)
82   endif
83 endforeach
84
85 check_functions = [
86 # check token HAVE_ACM
87 # check token HAVE_ANDROID_MEDIA
88 # check token HAVE_APEXSINK
89 # check token HAVE_APPLE_MEDIA
90 # check token HAVE_ASSRENDER
91 # check token HAVE_AVC
92 # check token HAVE_AVFOUNDATION
93 # check token HAVE_BLUEZ
94 # check token HAVE_BZ2
95 # check token HAVE_CFLOCALECOPYCURRENT
96 # check token HAVE_CFPREFERENCESCOPYAPPVALUE
97 # check token HAVE_CHROMAPRINT
98 # check token HAVE_CPU_ALPHA
99 # check token HAVE_CPU_ARM
100 # check token HAVE_CPU_CRIS
101 # check token HAVE_CPU_CRISV32
102 # check token HAVE_CPU_HPPA
103 # check token HAVE_CPU_I386
104 # check token HAVE_CPU_IA64
105 # check token HAVE_CPU_M68K
106 # check token HAVE_CPU_MIPS
107 # check token HAVE_CPU_PPC
108 # check token HAVE_CPU_PPC64
109 # check token HAVE_CPU_S390
110 # check token HAVE_CPU_SPARC
111 # check token HAVE_CPU_X86_64
112 # check token HAVE_CURL
113 # check token HAVE_DAALA
114 # check token HAVE_DASH
115 # check token HAVE_DC1394
116   ['HAVE_DCGETTEXT', 'dcgettext'],
117 # check token HAVE_DECKLINK
118 # check token HAVE_DIRECT3D
119 # check token HAVE_DIRECTDRAW
120 # check token HAVE_DIRECTFB
121 # check token HAVE_DIRECTSOUND
122 # check token HAVE_DOWHILE_MACROS
123 # check token HAVE_DTS
124 # check token HAVE_DVB
125 # check token HAVE_EXPERIMENTAL
126 # check token HAVE_EXTERNAL
127 # check token HAVE_FAAC
128 # check token HAVE_FAAD
129 # check token HAVE_FBDEV
130 # check token HAVE_FIONREAD_IN_SYS_FILIO
131 # check token HAVE_FIONREAD_IN_SYS_IOCTL
132 # check token HAVE_FLITE
133 # check token HAVE_FLUIDSYNTH
134   ['HAVE_GETPAGESIZE', 'getpagesize'],
135 # check token HAVE_GETTEXT
136 # check token HAVE_GL
137 # check token HAVE_GLCHAR
138 # check token HAVE_GLEGLIMAGEOES
139 # check token HAVE_GLINTPTR
140 # check token HAVE_GLSIZEIPTR
141 # check token HAVE_GME
142   ['HAVE_GMTIME_R', 'gmtime_r'],
143 # check token HAVE_GRAPHENE
144 # check token HAVE_GSETTINGS
145 # check token HAVE_GSM
146 # check token HAVE_GUDEV
147 # check token HAVE_HLS
148 # check token HAVE_ICONV
149 # check token HAVE_IOS
150 # check token HAVE_JPEG
151 # check token HAVE_KATE
152 # check token HAVE_LADSPA
153 # check token HAVE_LIBGCRYPT
154 # check token HAVE_LIBGME_ACCURACY
155 # check token HAVE_LIBMMS
156 # check token HAVE_LIBNSL
157 # check token HAVE_LIBSOCKET
158 # check token HAVE_LIBUSB
159 # check token HAVE_LIBVISUAL
160 # check token HAVE_LINSYS
161 # check token HAVE_LRDF
162 # check token HAVE_LV2
163 # check token HAVE_MIMIC
164   ['HAVE_MMAP', 'mmap'],
165 # check token HAVE_MODPLUG
166 # check token HAVE_MPEG2ENC
167 # check token HAVE_MPG123
168 # check token HAVE_MPLEX
169 # check token HAVE_MUSEPACK
170 # check token HAVE_MYTHTV
171 # check token HAVE_NAS
172 # check token HAVE_NEON
173 # check token HAVE_NETTLE
174 # check token HAVE_OFA
175 # check token HAVE_OPENAL
176 # check token HAVE_OPENCV
177 # check token HAVE_OPENEXR
178 # check token HAVE_OPENJPEG
179 # check token HAVE_OPENJPEG_1
180 # check token HAVE_OPENNI2
181 # check token HAVE_OPENSLES
182 # check token HAVE_OPUS
183 # check token HAVE_ORC
184 # check token HAVE_OSX
185 # check token HAVE_OSX_VIDEO
186 # check token HAVE_PNG
187 # check token HAVE_PVR
188 # check token HAVE_QUICKTIME
189 # check token HAVE_RDTSC
190 # check token HAVE_RESINDVD
191 # check token HAVE_RSVG
192 # check token HAVE_RSVG_2_36_2
193 # check token HAVE_RTMP
194 # check token HAVE_SBC
195 # check token HAVE_SCHRO
196 # check token HAVE_SDL
197 # check token HAVE_SHM
198 # check token HAVE_SMOOTHSTREAMING
199 # check token HAVE_SNDFILE
200 # check token HAVE_SNDIO
201 # check token HAVE_SOUNDTOUCH
202 # check token HAVE_SOUNDTOUCH_1_4
203 # check token HAVE_SPANDSP
204 # check token HAVE_SPC
205 # check token HAVE_SRTP
206 # check token HAVE_SSH2
207 # check token HAVE_TELETEXTDEC
208 # check token HAVE_TIGER
209 # check token HAVE_TIMIDITY
210 # check token HAVE_UVCH264
211 # check token HAVE_VALGRIND
212 # check token HAVE_VCD
213 # check token HAVE_VDPAU
214 # check token HAVE_VIDEOTOOLBOX
215 # check token HAVE_VIDEOTOOLBOX_10_9_6
216 # check token HAVE_VOAACENC
217 # check token HAVE_VOAMRWBENC
218 # check token HAVE_WASAPI
219 # check token HAVE_WAYLAND
220 # check token HAVE_WEBP
221 # check token HAVE_WILDMIDI
222 # check token HAVE_WILDMIDI_0_2_2
223 # check token HAVE_WIN32
224 # check token HAVE_WININET
225 # check token HAVE_WINKS
226 # check token HAVE_WINSCREENCAP
227 # check token HAVE_XVID
228 # check token HAVE_ZBAR
229 ]
230
231 foreach f : check_functions
232   if cc.has_function(f.get(1))
233     cdata.set(f.get(0), 1)
234   endif
235 endforeach
236
237 cdata.set('SIZEOF_CHAR', cc.sizeof('char'))
238 cdata.set('SIZEOF_INT', cc.sizeof('int'))
239 cdata.set('SIZEOF_LONG', cc.sizeof('long'))
240 cdata.set('SIZEOF_SHORT', cc.sizeof('short'))
241 cdata.set('SIZEOF_VOIDP', cc.sizeof('void*'))
242
243 cdata.set('VERSION', '"@0@"'.format(gst_version))
244 cdata.set('PACKAGE', '"gst-plugins-bad"')
245 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
246 cdata.set('PACKAGE_BUGREPORT', '"http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer"')
247 cdata.set('PACKAGE_NAME', '"GStreamer Bad Plug-ins"')
248 cdata.set('GETTEXT_PACKAGE', '"gst-plugins-bad-1.0"')
249 cdata.set('GST_API_VERSION', '"@0@"'.format(api_version))
250 cdata.set('GST_PACKAGE_NAME', '"GStreamer Bad Plug-ins"')
251 cdata.set('GST_PACKAGE_ORIGIN', '"Unknown package origin"')
252 cdata.set('GST_LICENSE', '"LGPL"')
253 cdata.set('LIBDIR', '"@0@"'.format(get_option('libdir')))
254
255 # FIXME: This should be exposed as a configuration option
256 host_system = host_machine.system()
257 if host_system == 'linux'
258   cdata.set('DEFAULT_VIDEOSRC', '"v4l2src"')
259 elif host_system == 'osx'
260   cdata.set('DEFAULT_VIDEOSRC', '"avfvideosrc"')
261 else
262   cdata.set('DEFAULT_VIDEOSRC', '"videotestsrc"')
263 endif
264
265 # Mandatory GST deps
266 gst_dep = dependency('gstreamer-1.0', version : gst_req,
267   fallback : ['gstreamer', 'gst_dep'])
268 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
269   fallback : ['gstreamer', 'gst_base_dep'])
270 gstnet_dep = dependency('gstreamer-net-1.0', version : gst_req,
271   fallback : ['gstreamer', 'gst_net_dep'])
272 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
273   fallback : ['gstreamer', 'gst_controller_dep'])
274
275 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
276     fallback : ['gst-plugins-base', 'pbutils_dep'])
277 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
278     fallback : ['gst-plugins-base', 'allocators_dep'])
279 gstapp_dep = dependency('gstreamer-app-1.0', version : gst_req,
280     fallback : ['gst-plugins-base', 'app_dep'])
281 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
282     fallback : ['gst-plugins-base', 'audio_dep'])
283 gstfft_dep = dependency('gstreamer-fft-1.0', version : gst_req,
284     fallback : ['gst-plugins-base', 'fft_dep'])
285 gstriff_dep = dependency('gstreamer-riff-1.0', version : gst_req,
286     fallback : ['gst-plugins-base', 'riff_dep'])
287 gstrtp_dep = dependency('gstreamer-rtp-1.0', version : gst_req,
288     fallback : ['gst-plugins-base', 'rtp_dep'])
289 gstrtsp_dep = dependency('gstreamer-rtsp-1.0', version : gst_req,
290     fallback : ['gst-plugins-base', 'rtsp_dep'])
291 gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
292     fallback : ['gst-plugins-base', 'sdp_dep'])
293 gsttag_dep = dependency('gstreamer-tag-1.0', version : gst_req,
294     fallback : ['gst-plugins-base', 'tag_dep'])
295 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
296     fallback : ['gst-plugins-base', 'video_dep'])
297
298 libm = cc.find_library('m', required : false)
299 glib_dep = dependency('glib-2.0', version : glib_req)
300 gio_dep = dependency('gio-2.0', version : glib_req)
301 gmodule_dep = dependency('gmodule-2.0', version : glib_req)
302 x11_dep = dependency('x11', required : false)
303 # Used by dtls and hls
304 openssl_dep = dependency('openssl', version : '>= 1.0.1', required : false)
305
306 if x11_dep.found()
307   cdata.set('HAVE_X11', 1)
308 endif
309
310 mathlib = cc.find_library('m', required : false)
311
312 if host_machine.system() == 'windows'
313   winsock2 = [cc.find_library('ws2_32')]
314 else
315   winsock2 = []
316 endif
317
318 have_orcc = false
319 orcc_args = []
320 if get_option('use_orc') != 'no'
321   need_orc = get_option('use_orc') == 'yes'
322   # Used by various libraries/elements that use Orc code
323   orc_dep = dependency('orc-0.4', required : need_orc)
324   orcc = find_program('orcc', required : need_orc)
325   if orc_dep.found() and orcc.found()
326     have_orcc = true
327     orcc_args = [orcc, '--include', 'glib.h']
328     cdata.set('HAVE_ORC', 1)
329   else
330     message('Orc Compiler not found, will use backup C code')
331     cdata.set('DISABLE_ORC', 1)
332   endif
333 else
334   cdata.set('DISABLE_ORC', 1)
335 endif
336
337 configure_file(input : 'config.h.meson',
338   output : 'config.h',
339   configuration : cdata)
340
341 gst_plugins_bad_args = ['-DHAVE_CONFIG_H']
342 configinc = include_directories('.')
343 libsinc = include_directories('gst-libs')
344
345 vs_module_defs_dir = meson.current_source_dir() + '/win32/common/'
346
347 # Used by the *_mkenum.py helper scripts
348 glib_mkenums = find_program('glib-mkenums')
349
350 subdir('gst-libs')
351 subdir('gst')
352 subdir('sys')
353 subdir('ext')
354 subdir('pkgconfig')
355
356 python3 = find_program('python3')
357 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')