d3d11: Update build-time dependency
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / gst-libs / gst / d3d11 / meson.build
1 d3d11_sources = [
2   'gstd3d11bufferpool.cpp',
3   'gstd3d11device.cpp',
4   'gstd3d11format.cpp',
5   'gstd3d11memory.cpp',
6   'gstd3d11stagingbufferpool.cpp',
7   'gstd3d11utils.cpp',
8 ]
9
10 gstd3d11_dep = dependency('', required : false)
11
12 d3d11_option = get_option('d3d11')
13 if host_system != 'windows' or d3d11_option.disabled()
14   subdir_done()
15 endif
16
17 have_d3d11 = false
18 extra_c_args = [
19   '-DCOBJMACROS',
20 ]
21 extra_comm_args = [
22   '-DGST_USE_UNSTABLE_API',
23   '-DBUILDING_GST_D3D11',
24   '-DG_LOG_DOMAIN="GStreamer-D3D11"',
25 ]
26
27 have_d3d11sdk_h = false
28 have_dxgidebug_h = false
29 d3d11_winapi_app = false
30 d3d11_conf = configuration_data()
31
32 d3d11_lib = cc.find_library('d3d11', required : d3d11_option)
33 dxgi_lib = cc.find_library('dxgi', required : d3d11_option)
34 d3dcompiler_lib = cc.find_library('d3dcompiler', required: d3d11_option)
35 runtimeobject_lib = cc.find_library('runtimeobject', required : false)
36
37 have_d3d11 = d3d11_lib.found() and dxgi_lib.found() and cc.has_header('d3d11_4.h') and cc.has_header('dxgi1_6.h')
38 if not have_d3d11
39   if d3d11_option.enabled()
40     error('The d3d11 was enabled explicitly, but required dependencies were not found.')
41   endif
42   subdir_done()
43 endif
44
45 d3d11_winapi_desktop = cxx.compiles('''#include <winapifamily.h>
46     #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
47     #error "not win32"
48     #endif''',
49     dependencies: [d3d11_lib, dxgi_lib],
50     name: 'building for Win32')
51
52 if runtimeobject_lib.found() and d3dcompiler_lib.found()
53   d3d11_winapi_app = cxx.compiles('''#include <winapifamily.h>
54       #include <windows.applicationmodel.core.h>
55       #include <wrl.h>
56       #include <wrl/wrappers/corewrappers.h>
57       #include <d3d11_4.h>
58       #include <dxgi1_6.h>
59       #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
60       #error "not winrt"
61       #endif
62       #if (WINVER < 0x0A00)
63       #error "Windows 10 API is not guaranteed"
64       #endif''',
65       dependencies: [d3d11_lib, dxgi_lib, runtimeobject_lib],
66       name: 'building for WinRT')
67 endif
68
69 if not d3d11_winapi_desktop and not d3d11_winapi_app
70   error('Neither Desktop partition nor App partition')
71 endif
72
73 d3d11_winapi_only_app = d3d11_winapi_app and not d3d11_winapi_desktop
74 d3d11_conf.set10('GST_D3D11_WINAPI_ONLY_APP', d3d11_winapi_only_app)
75 d3d11_conf.set10('GST_D3D11_WINAPI_APP', d3d11_winapi_app)
76
77 # for enabling debug layer
78 # NOTE: Disable d3d11/dxgi debug layer in case of [UWP build + release CRT]
79 # WACK (Windows App Certification Kit) doesn't seem to be happy with
80 # the DXGIGetDebugInterface1 symbol.
81
82 # FIXME: Probably DXGIGetDebugInterface1 might be used on UWP app for development
83 # purpose. So, I suspect one possible reason why WACK is complaining about
84 # DXGIGetDebugInterface1 is that debugging APIs couldn't be used for
85 # Windows store app, but couldn't find any reference about that.
86 #
87 # [IDXGIDebug1]
88 # https://docs.microsoft.com/en-us/windows/win32/api/dxgidebug/nn-dxgidebug-idxgidebug1
89 # is saying that the IDXGIDebug1 interface is available for both desktop app and
90 # UWP. And then the *DXGIGetDebugInterface1* method need to be called to obtain
91 # the IDXGIDebug1 interface.
92 #
93 # [DXGIGetDebugInterface1]
94 # https://docs.microsoft.com/en-us/windows/win32/api/dxgi1_3/nf-dxgi1_3-dxgigetdebuginterface1
95 # is mentioning that DXGIGetDebugInterface1 is desktop app only.
96 #
97 # PLEASE LET US KNOW A CORRECT WAY TO OBTAIN IDXGIDebug1 ON UWP, MICROSOFT
98 if get_option('debug') and not (d3d11_winapi_only_app and get_option('b_vscrt') == 'md')
99   d3d11_debug_libs = [
100     ['d3d11sdklayers.h', 'ID3D11Debug', 'ID3D11InfoQueue', 'have_d3d11sdk_h'],
101     ['dxgidebug.h', 'IDXGIDebug', 'IDXGIInfoQueue', 'have_dxgidebug_h'],
102   ]
103
104   foreach f : d3d11_debug_libs
105     header = f.get(0)
106     debug_obj = f.get(1)
107     info_obj = f.get(2)
108     compile_code = '''
109                    #include <d3d11.h>
110                    #include <dxgi.h>
111                    #include <@0@>
112                    int main(int arc, char ** argv) {
113                      @1@ *debug = NULL;
114                      @2@ *info_queue = NULL;
115                      return 0;
116                    }'''.format(header, debug_obj, info_obj)
117     if cc.compiles(compile_code, dependencies: [d3d11_lib, dxgi_lib], name: debug_obj)
118       set_variable(f.get(3), true)
119     endif
120   endforeach
121 else
122   message('Disable D3D11Debug and DXGIDebug layers')
123 endif
124
125 # don't need to be defined in gstd3d11config.h since it's gstd3d11device internal
126 if have_d3d11sdk_h
127   extra_comm_args += ['-DHAVE_D3D11SDKLAYERS_H']
128 endif
129
130 if have_dxgidebug_h
131   extra_comm_args += ['-DHAVE_DXGIDEBUG_H']
132 endif
133
134 # MinGW 32bits compiler seems to be complaining about redundant-decls
135 # when ComPtr is in use. Let's just disable the warning
136 if cc.get_id() != 'msvc'
137   extra_args = cc.get_supported_arguments([
138     '-Wno-redundant-decls',
139   ])
140
141   extra_comm_args += extra_args
142 endif
143
144 configure_file(
145   output: 'gstd3d11config.h',
146   configuration: d3d11_conf,
147 )
148
149 pkg_name = 'gstreamer-d3d11-' + api_version
150 gstd3d11 = library('gstd3d11-' + api_version,
151   d3d11_sources,
152   c_args : gst_plugins_bad_args + extra_c_args + extra_comm_args,
153   cpp_args : gst_plugins_bad_args + extra_comm_args,
154   include_directories : [configinc, libsinc],
155   version : libversion,
156   soversion : soversion,
157   install : true,
158   dependencies : [gstbase_dep, gstvideo_dep, gmodule_dep, d3d11_lib, dxgi_lib]
159 )
160
161 library_def = {'lib': gstd3d11}
162 libraries += [[pkg_name, library_def]]
163
164 # Still non-public api, should not install headers
165 gstd3d11_dep = declare_dependency(link_with : gstd3d11,
166   include_directories : [libsinc],
167   dependencies : [gstbase_dep, gstvideo_dep, gmodule_dep, d3d11_lib, dxgi_lib])