meson: add 'gpl' option and only build plugins with (A)GPL deps if explicitly enabled
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / ext / mpeg2enc / meson.build
1 mpeg2enc_opt = get_option('mpeg2enc').require(gpl_allowed, error_message: '''
2   Plugin mpeg2enc explicitly required via options but GPL-licensed plugins disabled via options.
3   Pass option -Dgpl=enabled to Meson to allow GPL-licensed plugins to be built.
4   ''')
5
6 # mjpegtools upstream breaks API constantly and doesn't export the version in
7 # a header anywhere. The configure file has a lot of logic to support old
8 # versions, but it all seems untested and broken. Require 2.0.0. Can be changed
9 # if someone complains.
10 mjpegtools_dep = dependency('mjpegtools', version : '>=2.0.0', required : mpeg2enc_opt)
11 mpeg2enc_dep = cxx.find_library('mpeg2encpp', required : mpeg2enc_opt)
12
13 if mjpegtools_dep.found() and mpeg2enc_dep.found()
14   no_warn_args = []
15   foreach arg : [
16       '-Wno-mismatched-tags', # mjpeg headers get class/struct mixed up
17       '-Wno-header-guard',
18     ]
19     if cxx.has_argument(arg)
20       no_warn_args += [arg]
21     endif
22   endforeach
23
24   gstmpeg2enc = library('gstmpeg2enc',
25     'gstmpeg2enc.cc',
26     'gstmpeg2encoptions.cc',
27     'gstmpeg2encoder.cc',
28     'gstmpeg2encstreamwriter.cc',
29     'gstmpeg2encpicturereader.cc',
30     cpp_args : gst_plugins_bad_args + ['-DGST_MJPEGTOOLS_API=20000'] + no_warn_args,
31     link_args : noseh_link_args,
32     include_directories : [configinc, libsinc],
33     dependencies : [gstvideo_dep, mjpegtools_dep, mpeg2enc_dep],
34     install : true,
35     install_dir : plugins_install_dir,
36   )
37   pkgconfig.generate(gstmpeg2enc, install_dir : plugins_pkgconfig_install_dir)
38   plugins += [gstmpeg2enc]
39 endif