opencv: Fixup include to follow new standard
[platform/upstream/gstreamer.git] / meson.build
1 project('gst-plugins-bad', 'c', 'cpp',
2   version : '1.15.0.1',
3   meson_version : '>= 0.47',
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 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 * 100 + gst_version_micro)
26
27 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
28
29 cc = meson.get_compiler('c')
30 cxx = meson.get_compiler('cpp')
31
32 if cc.get_id() == 'msvc'
33   # Ignore several spurious warnings for things gstreamer does very commonly
34   # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
35   # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
36   # NOTE: Only add warnings here if you are sure they're spurious
37   msvc_args = [
38       '/wd4018', # implicit signed/unsigned conversion
39       '/wd4146', # unary minus on unsigned (beware INT_MIN)
40       '/wd4244', # lossy type conversion (e.g. double -> int)
41       '/wd4305', # truncating type conversion (e.g. double -> float)
42   ]
43   add_project_arguments(msvc_args, language : 'c')
44   add_project_arguments(msvc_args, language : 'cpp')
45   # Disable SAFESEH with MSVC for plugins and libs that use external deps that
46   # are built with MinGW
47   noseh_link_args = ['/SAFESEH:NO']
48 else
49   if cxx.has_argument('-Wno-non-virtual-dtor')
50     add_project_arguments('-Wno-non-virtual-dtor', language: 'cpp')
51   endif
52
53   noseh_link_args = []
54 endif
55
56 if cc.has_link_argument('-Wl,-Bsymbolic-functions')
57   add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
58 endif
59
60 # Symbol visibility
61 if cc.has_argument('-fvisibility=hidden')
62   add_project_arguments('-fvisibility=hidden', language: 'c')
63 endif
64 if cxx.has_argument('-fvisibility=hidden')
65   add_project_arguments('-fvisibility=hidden', language: 'cpp')
66 endif
67
68 # Disable strict aliasing
69 if cc.has_argument('-fno-strict-aliasing')
70   add_project_arguments('-fno-strict-aliasing', language: 'c')
71 endif
72 if cxx.has_argument('-fno-strict-aliasing')
73   add_project_arguments('-fno-strict-aliasing', language: 'cpp')
74 endif
75
76 cdata = configuration_data()
77 check_headers = [
78   ['HAVE_DLFCN_H', 'dlfcn.h'],
79   ['HAVE_FCNTL_H', 'fcntl.h'],
80   ['HAVE_INTTYPES_H', 'inttypes.h'],
81   ['HAVE_MEMORY_H', 'memory.h'],
82   ['HAVE_MSACM_H', 'msacm.h'],
83   ['HAVE_NETINET_IN_H', 'netinet/in.h'],
84   ['HAVE_NETINET_IP_H', 'netinet/ip.h'],
85   ['HAVE_NETINET_TCP_H', 'netinet/tcp.h'],
86   ['HAVE_PTHREAD_H', 'pthread.h'],
87   ['HAVE_STDINT_H', 'stdint.h'],
88   ['HAVE_STDLIB_H', 'stdlib.h'],
89   ['HAVE_STRINGS_H', 'strings.h'],
90   ['HAVE_STRING_H', 'string.h'],
91   ['HAVE_SYS_PARAM_H', 'sys/param.h'],
92   ['HAVE_SYS_SOCKET_H', 'sys/socket.h'],
93   ['HAVE_SYS_STAT_H', 'sys/stat.h'],
94   ['HAVE_SYS_TIME_H', 'sys/time.h'],
95   ['HAVE_SYS_TYPES_H', 'sys/types.h'],
96   ['HAVE_SYS_UTSNAME_H', 'sys/utsname.h'],
97   ['HAVE_UNISTD_H', 'unistd.h'],
98   ['HAVE_WINDOWS_H', 'windows.h'],
99   ['HAVE_WINSOCK2_H', 'winsock2.h'],
100   ['HAVE_WS2TCPIP_H', 'ws2tcpip.h'],
101 ]
102
103 foreach h : check_headers
104   if cc.has_header(h.get(1))
105     cdata.set(h.get(0), 1)
106   endif
107 endforeach
108
109 check_functions = [
110 # check token HAVE_ACM
111 # check token HAVE_ANDROID_MEDIA
112 # check token HAVE_APEXSINK
113 # check token HAVE_APPLE_MEDIA
114 # check token HAVE_ASSRENDER
115 # check token HAVE_AVC
116 # check token HAVE_AVFOUNDATION
117 # check token HAVE_BLUEZ
118 # check token HAVE_BZ2
119 # check token HAVE_CFLOCALECOPYCURRENT
120 # check token HAVE_CFPREFERENCESCOPYAPPVALUE
121 # check token HAVE_CHROMAPRINT
122 # check token HAVE_CPU_ALPHA
123 # check token HAVE_CPU_ARM
124 # check token HAVE_CPU_CRIS
125 # check token HAVE_CPU_CRISV32
126 # check token HAVE_CPU_HPPA
127 # check token HAVE_CPU_I386
128 # check token HAVE_CPU_IA64
129 # check token HAVE_CPU_M68K
130 # check token HAVE_CPU_MIPS
131 # check token HAVE_CPU_PPC
132 # check token HAVE_CPU_PPC64
133 # check token HAVE_CPU_S390
134 # check token HAVE_CPU_SPARC
135 # check token HAVE_CPU_X86_64
136 # check token HAVE_CURL
137 # check token HAVE_DAALA
138 # check token HAVE_DASH
139 # check token HAVE_DC1394
140   ['HAVE_DCGETTEXT', 'dcgettext'],
141 # check token HAVE_DECKLINK
142 # check token HAVE_DIRECT3D
143 # check token HAVE_DIRECTDRAW
144 # check token HAVE_DIRECTFB
145 # check token HAVE_DIRECTSOUND
146 # check token HAVE_DOWHILE_MACROS
147 # check token HAVE_DTS
148 # check token HAVE_DVB
149 # check token HAVE_EXPERIMENTAL
150 # check token HAVE_EXTERNAL
151 # check token HAVE_FAAC
152 # check token HAVE_FAAD
153 # check token HAVE_FBDEV
154 # check token HAVE_FLITE
155 # check token HAVE_FLUIDSYNTH
156   ['HAVE_GETPAGESIZE', 'getpagesize'],
157 # check token HAVE_GETTEXT
158 # check token HAVE_GL
159 # check token HAVE_GLCHAR
160 # check token HAVE_GLEGLIMAGEOES
161 # check token HAVE_GLINTPTR
162 # check token HAVE_GLSIZEIPTR
163 # check token HAVE_GME
164   ['HAVE_GMTIME_R', 'gmtime_r'],
165 # check token HAVE_GRAPHENE
166 # check token HAVE_GSETTINGS
167 # check token HAVE_GSM
168 # check token HAVE_GUDEV
169 # check token HAVE_HLS
170 # check token HAVE_ICONV
171 # check token HAVE_IOS
172 # check token HAVE_JPEG
173 # check token HAVE_KATE
174 # check token HAVE_LADSPA
175 # check token HAVE_LIBGCRYPT
176 # check token HAVE_LIBGME_ACCURACY
177 # check token HAVE_LIBMMS
178 # check token HAVE_LIBNSL
179 # check token HAVE_LIBSOCKET
180 # check token HAVE_LIBUSB
181 # check token HAVE_LIBVISUAL
182 # check token HAVE_LINSYS
183 # check token HAVE_LRDF
184 # check token HAVE_LV2
185 # check token HAVE_MIMIC
186   ['HAVE_MMAP', 'mmap'],
187 # check token HAVE_MODPLUG
188 # check token HAVE_MPEG2ENC
189 # check token HAVE_MPG123
190 # check token HAVE_MPLEX
191 # check token HAVE_MUSEPACK
192 # check token HAVE_MYTHTV
193 # check token HAVE_NAS
194 # check token HAVE_NEON
195 # check token HAVE_NETTLE
196 # check token HAVE_OFA
197 # check token HAVE_OPENAL
198 # check token HAVE_OPENCV
199 # check token HAVE_OPENEXR
200 # check token HAVE_OPENJPEG
201 # check token HAVE_OPENJPEG_1
202 # check token HAVE_OPENNI2
203 # check token HAVE_OPENSLES
204 # check token HAVE_OPUS
205 # check token HAVE_ORC
206 # check token HAVE_OSX
207 # check token HAVE_OSX_VIDEO
208   ['HAVE_PIPE2', 'pipe2'],
209 # check token HAVE_PNG
210 # check token HAVE_PVR
211 # check token HAVE_QUICKTIME
212 # check token HAVE_RDTSC
213 # check token HAVE_RESINDVD
214 # check token HAVE_RSVG
215 # check token HAVE_RSVG_2_36_2
216 # check token HAVE_RTMP
217 # check token HAVE_SBC
218 # check token HAVE_SDL
219 # check token HAVE_SHM
220 # check token HAVE_SMOOTHSTREAMING
221 # check token HAVE_SNDFILE
222 # check token HAVE_SNDIO
223 # check token HAVE_SOUNDTOUCH
224 # check token HAVE_SOUNDTOUCH_1_4
225 # check token HAVE_SPANDSP
226 # check token HAVE_SPC
227 # check token HAVE_SRTP
228 # check token HAVE_SSH2
229 # check token HAVE_TELETEXTDEC
230 # check token HAVE_TIGER
231 # check token HAVE_TIMIDITY
232 # check token HAVE_UVCH264
233 # check token HAVE_VALGRIND
234 # check token HAVE_VCD
235 # check token HAVE_VDPAU
236 # check token HAVE_VIDEOTOOLBOX
237 # check token HAVE_VIDEOTOOLBOX_10_9_6
238 # check token HAVE_VOAACENC
239 # check token HAVE_VOAMRWBENC
240 # check token HAVE_WASAPI
241 # check token HAVE_WAYLAND
242 # check token HAVE_WEBP
243 # check token HAVE_WILDMIDI
244 # check token HAVE_WIN32
245 # check token HAVE_WININET
246 # check token HAVE_WINKS
247 # check token HAVE_WINSCREENCAP
248 # check token HAVE_XVID
249 # check token HAVE_ZBAR
250 ]
251
252 foreach f : check_functions
253   if cc.has_function(f.get(1))
254     cdata.set(f.get(0), 1)
255   endif
256 endforeach
257
258 cdata.set('SIZEOF_CHAR', cc.sizeof('char'))
259 cdata.set('SIZEOF_INT', cc.sizeof('int'))
260 cdata.set('SIZEOF_LONG', cc.sizeof('long'))
261 cdata.set('SIZEOF_SHORT', cc.sizeof('short'))
262 cdata.set('SIZEOF_VOIDP', cc.sizeof('void*'))
263
264 cdata.set_quoted('VERSION', gst_version)
265 cdata.set_quoted('PACKAGE', 'gst-plugins-bad')
266 cdata.set_quoted('PACKAGE_VERSION', gst_version)
267 cdata.set_quoted('PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer')
268 cdata.set_quoted('PACKAGE_NAME', 'GStreamer Bad Plug-ins')
269 cdata.set_quoted('GETTEXT_PACKAGE', 'gst-plugins-bad-1.0')
270 cdata.set_quoted('GST_API_VERSION', api_version)
271 cdata.set_quoted('GST_LICENSE', 'LGPL')
272 cdata.set_quoted('LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
273 cdata.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
274
275 warning_flags = [
276   '-Wmissing-declarations',
277   '-Wredundant-decls',
278   '-Wwrite-strings',
279   '-Wformat',
280   '-Wformat-security',
281   '-Winit-self',
282   '-Wmissing-include-dirs',
283   '-Waddress',
284   '-Wno-multichar',
285   '-Wvla',
286   '-Wpointer-arith',
287 ]
288
289 warning_c_flags = [
290   '-Wmissing-prototypes',
291   '-Wdeclaration-after-statement',
292   '-Wold-style-definition',
293   '-Wnested-externs',
294 ]
295
296 warning_cxx_flags = [
297   '-Wformat-nonliteral',
298 ]
299
300 foreach extra_arg : warning_c_flags
301   if cc.has_argument (extra_arg)
302     add_project_arguments([extra_arg], language: 'c')
303   endif
304 endforeach
305
306 foreach extra_arg : warning_cxx_flags
307   if cxx.has_argument (extra_arg)
308     add_project_arguments([extra_arg], language: 'cpp')
309   endif
310 endforeach
311
312 foreach extra_arg : warning_flags
313   if cc.has_argument (extra_arg)
314     add_project_arguments([extra_arg], language: 'c')
315   endif
316   if cxx.has_argument (extra_arg)
317     add_project_arguments([extra_arg], language: 'cpp')
318   endif
319 endforeach
320
321 # GStreamer package name and origin url
322 gst_package_name = get_option('package-name')
323 if gst_package_name == ''
324   if gst_version_nano == 0
325     gst_package_name = 'GStreamer Bad Plug-ins source release'
326   elif gst_version_nano == 1
327     gst_package_name = 'GStreamer Bad Plug-ins git'
328   else
329     gst_package_name = 'GStreamer Bad Plug-ins prerelease'
330   endif
331 endif
332 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
333 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
334
335 # FIXME: This should be exposed as a configuration option
336 host_system = host_machine.system()
337 if host_system == 'linux'
338   cdata.set_quoted('DEFAULT_VIDEOSRC', 'v4l2src')
339 elif host_system == 'osx'
340   cdata.set_quoted('DEFAULT_VIDEOSRC', 'avfvideosrc')
341 else
342   cdata.set_quoted('DEFAULT_VIDEOSRC', 'videotestsrc')
343 endif
344
345 if host_system == 'darwin'
346   cdata.set_quoted('GST_EXTRA_MODULE_SUFFIX', '.dylib')
347 endif
348
349 # Mandatory GST deps
350 gst_dep = dependency('gstreamer-1.0', version : gst_req,
351   fallback : ['gstreamer', 'gst_dep'])
352 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
353   fallback : ['gstreamer', 'gst_base_dep'])
354 gstnet_dep = dependency('gstreamer-net-1.0', version : gst_req,
355   fallback : ['gstreamer', 'gst_net_dep'])
356 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
357   fallback : ['gstreamer', 'gst_controller_dep'])
358
359 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
360     fallback : ['gst-plugins-base', 'pbutils_dep'])
361 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
362     fallback : ['gst-plugins-base', 'allocators_dep'])
363 gstapp_dep = dependency('gstreamer-app-1.0', version : gst_req,
364     fallback : ['gst-plugins-base', 'app_dep'])
365 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
366     fallback : ['gst-plugins-base', 'audio_dep'])
367 gstfft_dep = dependency('gstreamer-fft-1.0', version : gst_req,
368     fallback : ['gst-plugins-base', 'fft_dep'])
369 gstriff_dep = dependency('gstreamer-riff-1.0', version : gst_req,
370     fallback : ['gst-plugins-base', 'riff_dep'])
371 gstrtp_dep = dependency('gstreamer-rtp-1.0', version : gst_req,
372     fallback : ['gst-plugins-base', 'rtp_dep'])
373 gstrtsp_dep = dependency('gstreamer-rtsp-1.0', version : gst_req,
374     fallback : ['gst-plugins-base', 'rtsp_dep'])
375 gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
376     fallback : ['gst-plugins-base', 'sdp_dep'])
377 gsttag_dep = dependency('gstreamer-tag-1.0', version : gst_req,
378     fallback : ['gst-plugins-base', 'tag_dep'])
379 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
380     fallback : ['gst-plugins-base', 'video_dep'])
381 if host_machine.system() != 'windows'
382   gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
383     fallback : ['gstreamer', 'gst_check_dep'])
384 endif
385
386 # GStreamer OpenGL
387 gstgl_dep = dependency('gstreamer-gl-1.0', version : gst_req,
388     fallback : ['gst-plugins-base', 'gstgl_dep'], required: get_option('gl'))
389
390 if gstgl_dep.found()
391   if gstgl_dep.type_name() == 'pkgconfig'
392     gst_gl_apis = gstgl_dep.get_pkgconfig_variable('gl_apis').split()
393     gst_gl_winsys = gstgl_dep.get_pkgconfig_variable('gl_winsys').split()
394     gst_gl_platforms = gstgl_dep.get_pkgconfig_variable('gl_platforms').split()
395   else
396     gstbase = subproject('gst-plugins-base')
397     gst_gl_apis = gstbase.get_variable('enabled_gl_apis')
398     gst_gl_winsys = gstbase.get_variable('enabled_gl_winsys')
399     gst_gl_platforms = gstbase.get_variable('enabled_gl_platforms')
400   endif
401
402   message('GStreamer OpenGL window systems: @0@'.format(' '.join(gst_gl_winsys)))
403   message('GStreamer OpenGL platforms: @0@'.format(' '.join(gst_gl_platforms)))
404   message('GStreamer OpenGL apis: @0@'.format(' '.join(gst_gl_apis)))
405
406   foreach ws : ['x11', 'wayland', 'android', 'cocoa', 'eagl', 'win32', 'dispmanx', 'viv_fb']
407     set_variable('gst_gl_have_window_@0@'.format(ws), gst_gl_winsys.contains(ws))
408   endforeach
409
410   foreach p : ['glx', 'egl', 'cgl', 'eagl', 'wgl']
411     set_variable('gst_gl_have_platform_@0@'.format(p), gst_gl_platforms.contains(p))
412   endforeach
413
414   foreach api : ['opengl', 'gles2']
415     set_variable('gst_gl_have_api_@0@'.format(api), gst_gl_apis.contains(api))
416   endforeach
417 endif
418
419 libm = cc.find_library('m', required : false)
420 glib_dep = dependency('glib-2.0', version : glib_req, fallback: ['glib', 'libglib_dep'])
421 gmodule_dep = dependency('gmodule-2.0', fallback: ['glib', 'libgmodule_dep'])
422 gio_dep = dependency('gio-2.0', fallback: ['glib', 'libgio_dep'])
423 # gio-unix-2.0 is used by sys/bluez
424
425 # Optional dep of ext/gl and gst/librfb
426 x11_dep = dependency('x11', required : get_option('x11'))
427 if x11_dep.found()
428   cdata.set('HAVE_X11', 1)
429 endif
430
431 if host_machine.system() == 'windows'
432   winsock2 = [cc.find_library('ws2_32')]
433 else
434   winsock2 = []
435 endif
436
437 have_orcc = false
438 orcc_args = []
439 # Used by various libraries/elements that use Orc code
440 orc_dep = dependency('orc-0.4', required : get_option('orc'))
441 orcc = find_program('orcc', required : get_option('orc'))
442 if orc_dep.found() and orcc.found()
443   have_orcc = true
444   orcc_args = [orcc, '--include', 'glib.h']
445   cdata.set('HAVE_ORC', 1)
446 else
447   message('Orc Compiler not found or disabled, will use backup C code')
448   cdata.set('DISABLE_ORC', 1)
449 endif
450
451 if gst_dep.type_name() == 'internal'
452   gst_debug_disabled = not subproject('gstreamer').get_variable('gst_debug')
453 else
454   # We can't check that in the case of subprojects as we won't
455   # be able to build against an internal dependency (which is not built yet)
456   gst_debug_disabled = cc.has_header_symbol('gst/gstconfig.h', 'GST_DISABLE_GST_DEBUG', dependencies: gst_dep)
457 endif
458
459 if gst_debug_disabled and cc.has_argument('-Wno-unused')
460   add_project_arguments('-Wno-unused', language: 'c')
461 endif
462
463 gst_plugins_bad_args = ['-DHAVE_CONFIG_H']
464 configinc = include_directories('.')
465 libsinc = include_directories('gst-libs')
466
467 python3 = import('python3').find_python()
468
469 gir = find_program('g-ir-scanner', required : get_option('introspection'))
470 gnome = import('gnome')
471 build_gir = gir.found() and not meson.is_cross_build()
472 gir_init_section = [ '--add-init-section=extern void gst_init(gint*,gchar**);' + \
473     'g_setenv("GST_REGISTRY_1.0", "@0@", TRUE);'.format(meson.current_build_dir() + '/gir_empty_registry.reg') + \
474     'g_setenv("GST_PLUGIN_PATH_1_0", "", TRUE);' + \
475     'g_setenv("GST_PLUGIN_SYSTEM_PATH_1_0", "", TRUE);' + \
476     'gst_init(NULL,NULL);' ]
477
478 pkgconfig = import('pkgconfig')
479 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
480 if get_option('default_library') == 'shared'
481   # If we don't build static plugins there is no need to generate pc files
482   plugins_pkgconfig_install_dir = disabler()
483 endif
484
485 subdir('gst-libs')
486 subdir('gst')
487 subdir('sys')
488 subdir('ext')
489 subdir('tests')
490 subdir('pkgconfig')
491
492 # xgettext is optional (on Windows for instance)
493 if find_program('xgettext', required : get_option('nls')).found()
494   cdata.set('ENABLE_NLS', 1)
495   subdir('po')
496 endif
497
498 configure_file(output : 'config.h', configuration : cdata)
499
500 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')