meson: don't add_global_arguments when being built as a subproject
[platform/upstream/gst-plugins-good.git] / meson.build
1 project('gst-plugins-good', 'c', 'cpp',
2   version : '1.11.0.1',
3   meson_version : '>= 0.35.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
23 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
24
25 cc = meson.get_compiler('c')
26
27 if cc.get_id() == 'msvc'
28   # Ignore several spurious warnings for things gstreamer does very commonly
29   # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
30   # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
31   # NOTE: Only add warnings here if you are sure they're spurious
32   if not meson.is_subproject()
33     add_global_arguments('/wd4018', '/wd4244', '/wd4996', language : 'c')
34   endif
35   # Disable SAFESEH with MSVC for plugins and libs that use external deps that
36   # are built with MinGW
37   noseh_link_args = ['/SAFESEH:NO']
38 else
39   noseh_link_args = []
40 endif
41
42 cdata = configuration_data()
43
44 check_headers = [
45   ['HAVE_DLFCN_H', 'dlfcn.h'],
46   ['HAVE_FCNTL_H', 'fcntl.h'],
47   ['HAVE_INTTYPES_H', 'inttypes.h'],
48   ['HAVE_MEMORY_H', 'memory.h'],
49   ['HAVE_PROCESS_H', 'process.h'],
50   ['HAVE_STDINT_H', 'stdint.h'],
51   ['HAVE_STDLIB_H', 'stdlib.h'],
52   ['HAVE_STRINGS_H', 'strings.h'],
53   ['HAVE_STRING_H', 'string.h'],
54   ['HAVE_SYS_IOCTL_H', 'sys/ioctl.h'],
55   ['HAVE_SYS_PARAM_H', 'sys/param.h'],
56   ['HAVE_SYS_SOCKET_H', 'sys/socket.h'],
57   ['HAVE_SYS_STAT_H', 'sys/stat.h'],
58   ['HAVE_SYS_TIME_H', 'sys/time.h'],
59   ['HAVE_SYS_TYPES_H', 'sys/types.h'],
60   ['HAVE_UNISTD_H', 'unistd.h'],
61 ]
62
63 foreach h : check_headers
64   if cc.has_header(h.get(1))
65     cdata.set(h.get(0), 1)
66   endif
67 endforeach
68
69 check_functions = [
70   ['HAVE_ASINH', 'asinh', '#include<math.h>'],
71   ['HAVE_CLOCK_GETTIME', 'clock_gettime', '#include<time.h>'],
72   ['HAVE_COSH', 'cosh', '#include<math.h>'],
73 # check token HAVE_CPU_ALPHA
74 # check token HAVE_CPU_ARM
75 # check token HAVE_CPU_CRIS
76 # check token HAVE_CPU_CRISV32
77 # check token HAVE_CPU_HPPA
78 # check token HAVE_CPU_I386
79 # check token HAVE_CPU_IA64
80 # check token HAVE_CPU_M68K
81 # check token HAVE_CPU_MIPS
82 # check token HAVE_CPU_PPC
83 # check token HAVE_CPU_PPC64
84 # check token HAVE_CPU_S390
85 # check token HAVE_CPU_SPARC
86 # check token HAVE_CPU_X86_64
87   ['HAVE_DCGETTEXT', 'dcgettext', '#include<libintl.h>'],
88 # check token HAVE_DIRECTSOUND
89 # check token HAVE_EXPERIMENTAL
90 # check token HAVE_EXTERNAL
91 # check token HAVE_FPCLASS
92 # check token HAVE_GCC_ASM
93   ['HAVE_GETPAGESIZE', 'getpagesize', '#include<unistd.h>'],
94 # check token HAVE_GETTEXT
95 # check token HAVE_GST_V4L2
96 # check token HAVE_IOS
97   ['HAVE_ISINF', 'isinf', '#include<math.h>'],
98 # check token HAVE_LIBV4L2
99   ['HAVE_MMAP', 'mmap', '#include<sys/mman.h>'],
100 # check token HAVE_OSS
101 # check token HAVE_OSS4
102 # check token HAVE_OSS_INCLUDE_IN_MACHINE
103 # check token HAVE_OSS_INCLUDE_IN_ROOT
104 # check token HAVE_OSS_INCLUDE_IN_SYS
105 # check token HAVE_OSX_AUDIO
106 # check token HAVE_OSX_VIDEO
107 # check token HAVE_RDTSC
108   ['HAVE_SINH', 'sinh', '#include<math.h>'],
109 # check token HAVE_SUNAUDIO
110 # check token HAVE_WAVEFORM
111 ]
112
113 foreach f : check_functions
114   if cc.has_function(f.get(1), prefix : f.get(2))
115     cdata.set(f.get(0), 1)
116   endif
117 endforeach
118
119 cdata.set('SIZEOF_CHAR', cc.sizeof('char'))
120 cdata.set('SIZEOF_INT', cc.sizeof('int'))
121 cdata.set('SIZEOF_LONG', cc.sizeof('long'))
122 cdata.set('SIZEOF_SHORT', cc.sizeof('short'))
123 cdata.set('SIZEOF_VOIDP', cc.sizeof('void*'))
124
125 # Here be fixmes.
126 # FIXME: check if this is correct
127 cdata.set('HAVE_CPU_X86_64', host_machine.cpu() == 'amd64')
128 cdata.set('HAVE_GCC_ASM', cc.get_id() != 'msvc')
129 cdata.set('VERSION', '"@0@"'.format(gst_version))
130 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
131 cdata.set('GST_LICENSE', '"LGPL"')
132 cdata.set('PACKAGE', '"gst-plugins-good"')
133 cdata.set('GETTEXT_PACKAGE', '"gst-plugins-good-1.0"')
134 cdata.set('PACKAGE_NAME', '"GStreamer Good Plug-ins"')
135 cdata.set('GST_PACKAGE_NAME', '"GStreamer Good Plug-ins"')
136 cdata.set('GST_PACKAGE_ORIGIN', '"Unknown package origin"') # FIXME: make configurable
137
138 # Mandatory GST deps
139 gst_dep = dependency('gstreamer-1.0', version : gst_req,
140   fallback : ['gstreamer', 'gst_dep'])
141 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
142   fallback : ['gstreamer', 'gst_base_dep'])
143 gstnet_dep = dependency('gstreamer-net-1.0', version : gst_req,
144   fallback : ['gstreamer', 'gst_net_dep'])
145 if host_machine.system() != 'windows'
146   gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
147     fallback : ['gstreamer', 'gst_check_dep'])
148 endif
149 gstcontroller_dep = dependency('gstreamer-controller-1.0', version : gst_req,
150   fallback : ['gstreamer', 'gst_controller_dep'])
151
152 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
153     fallback : ['gst-plugins-base', 'pbutils_dep'])
154 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
155     fallback : ['gst-plugins-base', 'allocators_dep'])
156 gstapp_dep = dependency('gstreamer-app-1.0', version : gst_req,
157     fallback : ['gst-plugins-base', 'app_dep'])
158 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
159     fallback : ['gst-plugins-base', 'audio_dep'])
160 gstfft_dep = dependency('gstreamer-fft-1.0', version : gst_req,
161     fallback : ['gst-plugins-base', 'fft_dep'])
162 gstriff_dep = dependency('gstreamer-riff-1.0', version : gst_req,
163     fallback : ['gst-plugins-base', 'riff_dep'])
164 gstrtp_dep = dependency('gstreamer-rtp-1.0', version : gst_req,
165     fallback : ['gst-plugins-base', 'rtp_dep'])
166 gstrtsp_dep = dependency('gstreamer-rtsp-1.0', version : gst_req,
167     fallback : ['gst-plugins-base', 'rtsp_dep'])
168 gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req,
169     fallback : ['gst-plugins-base', 'sdp_dep'])
170 gsttag_dep = dependency('gstreamer-tag-1.0', version : gst_req,
171     fallback : ['gst-plugins-base', 'tag_dep'])
172 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
173     fallback : ['gst-plugins-base', 'video_dep'])
174
175 libm = cc.find_library('m', required : false)
176 zlib_dep = dependency('zlib')
177 bz2lib = cc.find_library('bz2', required : false)
178 gio_dep = dependency('gio-2.0', version : glib_req)
179 glib_deps = [dependency('glib-2.0', version : glib_req),
180              dependency('gobject-2.0', version : glib_req)]
181
182 cdata.set('HAVE_ZLIB', 1)
183 if bz2lib.found()
184   cdata.set('HAVE_BZ2', 1)
185 endif
186
187 # Check all of the things.
188 # TODO: None of these are actually used yet because
189 # the build files haven't been written
190 deps = [
191   ['gtk_dep','gtk+-3.0', '', ''],
192   ['gtkx_dep','gtk+-x11-3.0', '', ''],
193   ['caca_dep','caca', '', ''],
194   ['libraw1394_dep','libraw1394', '>=2.0.0', ''],
195   ['libiec61883_dep','libiec61883', '>=1.0.0', ''],
196 ]
197
198 foreach d : deps
199   varname = d[0]
200   depname = d[1]
201   version = d[2]
202   confhname = d[3]
203   if version == ''
204     curdep = dependency(depname, required : false)
205   else
206     curdep = dependency(depname, required : false, version : version)
207   endif
208   set_variable(varname, curdep)
209   if curdep.found() and confhname != ''
210     cdata.set(confhname, 1)
211   endif
212 endforeach
213
214 gst_plugins_good_args = ['-DHAVE_CONFIG_H']
215 configinc = include_directories('.')
216 libsinc = include_directories('gst-libs')
217
218 have_orcc = false
219 orcc_args = []
220 if get_option('use_orc') != 'no'
221   need_orc = get_option('use_orc') == 'yes'
222   # Used by various libraries/elements that use Orc code
223   orc_dep = dependency('orc-0.4', version : '>= 0.4.17', required : need_orc)
224   orcc = find_program('orcc', required : need_orc)
225   if orc_dep.found() and orcc.found()
226     have_orcc = true
227     orcc_args = [orcc, '--include', 'glib.h']
228     cdata.set('HAVE_ORC', 1)
229   else
230     message('Orc Compiler not found, will use backup C code')
231     cdata.set('DISABLE_ORC', 1)
232   endif
233 else
234   cdata.set('DISABLE_ORC', 1)
235 endif
236
237 subdir('gst')
238 subdir('sys')
239 subdir('ext')
240 subdir('tests')
241 subdir('po')
242
243 configure_file(input : 'config.h.meson',
244   output : 'config.h',
245   configuration : cdata)
246
247 python3 = find_program('python3')
248 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')