d3d11: fix building with address sanitizer
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / sys / d3d11 / meson.build
1 d3d11_sources = [
2   'gstd3d11av1dec.cpp',
3   'gstd3d11basefilter.cpp',
4   'gstd3d11compositor.cpp',
5   'gstd3d11convert.cpp',
6   'gstd3d11decoder.cpp',
7   'gstd3d11deinterlace.cpp',
8   'gstd3d11download.cpp',
9   'gstd3d11h264dec.cpp',
10   'gstd3d11h265dec.cpp',
11   'gstd3d11mpeg2dec.cpp',
12   'gstd3d11overlaycompositor.cpp',
13   'gstd3d11pluginutils.cpp',
14   'gstd3d11testsrc.cpp',
15   'gstd3d11upload.cpp',
16   'gstd3d11videosink.cpp',
17   'gstd3d11vp8dec.cpp',
18   'gstd3d11vp9dec.cpp',
19   'gstd3d11window.cpp',
20   'gstd3d11window_dummy.cpp',
21   'plugin.cpp',
22 ]
23
24 extra_c_args = ['-DCOBJMACROS']
25 extra_args = ['-DGST_USE_UNSTABLE_API']
26 extra_dep = []
27
28 d3d11_option = get_option('d3d11')
29 if host_system != 'windows' or d3d11_option.disabled()
30   subdir_done()
31 endif
32
33 if not gstd3d11_dep.found() or not cc.has_header('dxva.h') or not cc.has_header('d3d9.h')
34   if d3d11_option.enabled()
35     error('The d3d11 was enabled explicitly, but required dependencies were not found.')
36   endif
37   subdir_done()
38 endif
39
40 runtimeobject_lib = cc.find_library('runtimeobject', required : false)
41 winmm_lib = cc.find_library('winmm', required: false)
42
43 if d3d11_winapi_only_app and (not d3dcompiler_lib.found() or not runtimeobject_lib.found())
44   if d3d11_option.enabled()
45     error('The d3d11 plugin was enabled explicitly, but required dependencies were not found.')
46   endif
47   subdir_done()
48 endif
49
50 have_wgc = cxx.compiles('''
51     #include<windows.h>
52     #include<winstring.h>
53     #include<roapi.h>
54     #include<windows.graphics.capture.h>,
55     #include<windows.graphics.capture.interop.h>
56     #include<windows.graphics.directx.direct3d11.h>
57     #include<windows.graphics.directx.direct3d11.interop.h>
58     #include<wrl.h>
59     using namespace Microsoft::WRL;
60     using namespace ABI::Windows::Graphics::Capture;
61     ComPtr<IDirect3D11CaptureFramePoolStatics> pool_statics;
62     ComPtr<IDirect3D11CaptureFramePoolStatics2> pool_statics2;
63     ComPtr<IDirect3D11CaptureFramePool> pool;
64     ComPtr<IGraphicsCaptureSession> session;
65     ComPtr<IGraphicsCaptureSession2> session2;
66     ComPtr<IGraphicsCaptureSession3> session3;
67     ''',
68     name: 'Windows Graphics Capture support in Windows SDK')
69
70 # if build target is Windows 10 and WINAPI_PARTITION_APP is allowed,
71 # we can build UWP only modules as well
72 if d3d11_winapi_app
73   d3d11_sources += ['gstd3d11window_corewindow.cpp',
74                     'gstd3d11window_swapchainpanel.cpp']
75   extra_dep += [runtimeobject_lib]
76   if cc.get_id() == 'msvc' and get_option('b_sanitize') == 'address'
77     extra_args += ['/bigobj']
78   endif
79 endif
80
81 if d3d11_winapi_desktop
82   d3d11_sources += ['gstd3d11dxgicapture.cpp',
83                     'gstd3d11screencapture.cpp',
84                     'gstd3d11screencapturedevice.cpp',
85                     'gstd3d11screencapturesrc.cpp',
86                     'gstd3d11window_win32.cpp']
87
88   # multimedia clock is desktop only API
89   if winmm_lib.found() and cc.has_header('mmsystem.h')
90     extra_args += ['-DHAVE_WINMM']
91     extra_dep += [winmm_lib]
92   endif
93
94   if have_wgc
95     d3d11_sources += ['gstd3d11winrtcapture.cpp']
96     extra_args += ['-DHAVE_WINRT_CAPTURE']
97   endif
98 endif
99
100 # MinGW 32bits compiler seems to be complaining about redundant-decls
101 # when ComPtr is in use. Let's just disable the warning
102 if cc.get_id() != 'msvc'
103   extra_mingw_args = cc.get_supported_arguments([
104     '-Wno-redundant-decls',
105   ])
106
107   extra_args += extra_mingw_args
108 endif
109
110 gstd3d11 = library('gstd3d11',
111   d3d11_sources,
112   c_args : gst_plugins_bad_args + extra_c_args + extra_args,
113   cpp_args: gst_plugins_bad_args + extra_args,
114   include_directories : [configinc],
115   dependencies : [gstbase_dep, gstvideo_dep, gmodule_dep, gstcontroller_dep, gstd3d11_dep, gstcodecs_dep] + extra_dep,
116   install : true,
117   install_dir : plugins_install_dir,
118 )
119 plugins += [gstd3d11]