vulkan: Add iOS window implementation
[platform/upstream/gst-plugins-bad.git] / ext / vulkan / meson.build
1 vulkan_sources = [
2   'gstvulkan.c',
3   'vkbuffermemory.c',
4   'vkbufferpool.c',
5   'vkdevice.c',
6   'vkdisplay.c',
7   'vkerror.c',
8   'vkfence.c',
9   'vkimagememory.c',
10   'vkinstance.c',
11   'vkmemory.c',
12   'vkqueue.c',
13   'vksink.c',
14   'vkswapper.c',
15   'vktrash.c',
16   'vkupload.c',
17   'vkutils.c',
18   'vkwindow.c',
19 ]
20
21 vulkan_objc_args = []
22 vulkan_defines = []
23 optional_deps = []
24 if get_option('vulkan').disabled()
25   subdir_done()
26 endif
27
28 if host_system == 'ios'
29   vulkan_dep = cc.find_library('MoltenVK', required : get_option('vulkan'))
30 else
31   vulkan_dep = cc.find_library('vulkan', required : get_option('vulkan'))
32 endif
33 has_vulkan_header = cc.has_header('vulkan/vulkan.h')
34 if not has_vulkan_header and get_option('vulkan').enabled()
35   error('vulkan plugin enabled, but vulkan.h not found')
36 endif
37
38 if vulkan_dep.found() and has_vulkan_header
39   have_vulkan_windowing = false
40
41   vkconf = configuration_data()
42
43   xcb_dep = dependency('xcb', version : '>=1.10', required : get_option('x11'))
44   if xcb_dep.found()
45     vulkan_sources += [
46       'xcb/vkdisplay_xcb.c',
47       'xcb/vkwindow_xcb.c',
48       'xcb/xcb_event_source.c',
49     ]
50
51     optional_deps += xcb_dep
52     have_vulkan_windowing = true
53     vkconf.set10('GST_VULKAN_HAVE_WINDOW_XCB', 1)
54   endif
55
56   wayland_client_dep = dependency('wayland-client', version : '>=1.4', required : get_option('wayland'))
57   if wayland_client_dep.found()
58     vulkan_sources += [
59       'wayland/vkdisplay_wayland.c',
60       'wayland/vkwindow_wayland.c',
61       'wayland/wayland_event_source.c',
62     ]
63
64     optional_deps += wayland_client_dep
65     have_vulkan_windowing = true
66     vkconf.set10('GST_VULKAN_HAVE_WINDOW_WAYLAND', 1)
67   endif
68
69   if ['darwin', 'ios'].contains(host_system)
70     objc = meson.get_compiler('objc')
71     if not objc.has_argument('-fobjc-arc')
72       error('ARC is required for building')
73     endif
74
75     vulkan_objc_args += ['-fobjc-arc']
76
77     foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : get_option('vulkan'))
78     quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : get_option('vulkan'))
79     corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : get_option('vulkan'))
80     if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found()
81       optional_deps += [foundation_dep, corefoundation_dep, quartzcore_dep]
82     endif
83   endif
84
85   if host_system == 'darwin'
86     cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : get_option('vulkan'))
87
88     if cocoa_dep.found()
89       vulkan_sources += [
90         'cocoa/vkdisplay_cocoa.m',
91         'cocoa/vkwindow_cocoa.m',
92       ]
93       optional_deps += [cocoa_dep]
94       have_vulkan_windowing = true
95       vkconf.set10('GST_VULKAN_HAVE_WINDOW_COCOA', 1)
96     endif
97   endif
98
99   if host_system == 'ios'
100     uikit_dep = dependency('appleframeworks', modules : ['UIKit'], required : get_option('vulkan'))
101
102     if uikit_dep.found()
103       vulkan_sources += [
104         'ios/vkdisplay_ios.m',
105         'ios/vkwindow_ios.m',
106       ]
107       optional_deps += [uikit_dep]
108       have_vulkan_windowing = true
109       vkconf.set10('GST_VULKAN_HAVE_WINDOW_IOS', 1)
110     endif
111   endif
112
113   if have_vulkan_windowing
114     configure_file(input : 'vkconfig.h.meson',
115       output : 'vkconfig.h',
116       configuration : vkconf)
117
118     gstvulkan = library('gstvulkan',
119       vulkan_sources,
120       c_args : gst_plugins_bad_args + vulkan_defines,
121       objc_args : gst_plugins_bad_args + vulkan_defines + vulkan_objc_args,
122       link_args : noseh_link_args,
123       include_directories : [configinc],
124       dependencies : [gstvideo_dep, gstbase_dep, vulkan_dep] + optional_deps,
125       install : true,
126       install_dir : plugins_install_dir,
127     )
128     pkgconfig.generate(gstvulkan, install_dir : plugins_pkgconfig_install_dir)
129   endif
130 endif
131