| 1 |
# TODO vulkan |
| 2 |
|
| 3 |
sources = [ |
| 4 |
'context.c', |
| 5 |
'init.c', |
| 6 |
'input.c', |
| 7 |
'monitor.c', |
| 8 |
'vulkan.c', |
| 9 |
'window.c', |
| 10 |
'platform.c', |
| 11 |
|
| 12 |
'null_init.c', |
| 13 |
'null_joystick.c', |
| 14 |
'null_monitor.c', |
| 15 |
'null_window.c', |
| 16 |
] |
| 17 |
|
| 18 |
dependencies = [threads_dep] |
| 19 |
|
| 20 |
if host_system == 'linux' or host_system == 'bsd' |
| 21 |
dependencies += [math_dep] |
| 22 |
|
| 23 |
if backend == 'x11' |
| 24 |
dependencies += [cc.find_library('dl', required: false)] |
| 25 |
endif |
| 26 |
endif |
| 27 |
|
| 28 |
conf_data = configuration_data() |
| 29 |
foreach b : ['cocoa', 'win32', 'x11', 'wayland', 'osmesa'] |
| 30 |
conf_data.set('_GLFW_' + b.to_upper(), backend == b) |
| 31 |
endforeach |
| 32 |
conf_data.set('_GLFW_BUILD_DLL', get_option('default_library') == 'shared') |
| 33 |
conf_data.set('_GLFW_VULKAN_STATIC', get_option('glfw_vulkan_static')) |
| 34 |
conf_data.set('_GLFW_USE_HYBRID_HPG', get_option('glfw_use_hybrid_hpg')) |
| 35 |
conf_file = configure_file(configuration: conf_data, output: 'glfw_config.h') |
| 36 |
sources += conf_file |
| 37 |
|
| 38 |
if (backend == 'wayland' or backend == 'x11') |
| 39 |
if host_system == 'linux' |
| 40 |
sources += ['linux_joystick.c'] |
| 41 |
else |
| 42 |
sources += ['null_joystick.c'] |
| 43 |
endif |
| 44 |
endif |
| 45 |
|
| 46 |
if backend == 'cocoa' |
| 47 |
add_languages('objc', native: false) |
| 48 |
|
| 49 |
dependencies += dependency( |
| 50 |
'appleframeworks', |
| 51 |
modules: ['Cocoa', 'IOKit', 'CoreFoundation', 'CoreVideo'], |
| 52 |
) |
| 53 |
|
| 54 |
sources += [ |
| 55 |
'cocoa_init.m', |
| 56 |
'cocoa_joystick.m', |
| 57 |
'cocoa_monitor.m', |
| 58 |
'cocoa_time.c', |
| 59 |
'cocoa_window.m', |
| 60 |
'egl_context.c', |
| 61 |
'nsgl_context.m', |
| 62 |
'osmesa_context.c', |
| 63 |
'posix_thread.c', |
| 64 |
'posix_module.c', |
| 65 |
] |
| 66 |
elif backend == 'win32' |
| 67 |
dependencies += cc.find_library('gdi32') |
| 68 |
|
| 69 |
sources += [ |
| 70 |
'egl_context.c', |
| 71 |
'osmesa_context.c', |
| 72 |
'wgl_context.c', |
| 73 |
'win32_init.c', |
| 74 |
'win32_joystick.c', |
| 75 |
'win32_monitor.c', |
| 76 |
'win32_thread.c', |
| 77 |
'win32_time.c', |
| 78 |
'win32_window.c', |
| 79 |
] |
| 80 |
elif backend == 'x11' |
| 81 |
dependencies += dependency('x11') |
| 82 |
# TODO: XRandR header found? |
| 83 |
# TODO: Xinerama header found? |
| 84 |
# TODO: Xkb header found? |
| 85 |
# TODO: Xcursor header found? |
| 86 |
sources += [ |
| 87 |
'egl_context.c', |
| 88 |
'glx_context.c', |
| 89 |
'osmesa_context.c', |
| 90 |
'posix_module.c', |
| 91 |
'posix_poll.c', |
| 92 |
'posix_thread.c', |
| 93 |
'posix_time.c', |
| 94 |
'x11_init.c', |
| 95 |
'x11_monitor.c', |
| 96 |
'x11_window.c', |
| 97 |
'xkb_unicode.c', |
| 98 |
] |
| 99 |
elif backend == 'wayland' |
| 100 |
wayland_client = dependency('wayland-client') |
| 101 |
|
| 102 |
wayland_scanner_dep = dependency('wayland-scanner', required: false, native: true) |
| 103 |
if wayland_scanner_dep.found() |
| 104 |
wayland_scanner = find_program( |
| 105 |
wayland_scanner_dep.get_pkgconfig_variable('wayland_scanner'), |
| 106 |
native: true, |
| 107 |
) |
| 108 |
else |
| 109 |
wayland_scanner = find_program('wayland-scanner', native: true) |
| 110 |
endif |
| 111 |
|
| 112 |
protocols = [ |
| 113 |
'wayland', |
| 114 |
'xdg-shell', |
| 115 |
'xdg-decoration-unstable-v1', |
| 116 |
'viewporter', |
| 117 |
'relative-pointer-unstable-v1', |
| 118 |
'pointer-constraints-unstable-v1', |
| 119 |
'idle-inhibit-unstable-v1', |
| 120 |
'xdg-activation-v1', |
| 121 |
'fractional-scale-v1', |
| 122 |
] |
| 123 |
|
| 124 |
wl_protos_src = [] |
| 125 |
wl_protos_headers = [] |
| 126 |
|
| 127 |
foreach name : protocols |
| 128 |
xml = meson.project_source_root() / 'deps/wayland' / f'@[email protected]' |
| 129 |
outsrc = f'@[email protected]' |
| 130 |
outhdr = f'@[email protected]' |
| 131 |
|
| 132 |
wl_protos_src += custom_target( |
| 133 |
xml.underscorify() + '_server_c', |
| 134 |
input: xml, |
| 135 |
output: outsrc, |
| 136 |
command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'], |
| 137 |
) |
| 138 |
|
| 139 |
wl_protos_headers += custom_target( |
| 140 |
xml.underscorify() + '_server_h', |
| 141 |
input: xml, |
| 142 |
output: outhdr, |
| 143 |
command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'], |
| 144 |
) |
| 145 |
endforeach |
| 146 |
|
| 147 |
dependencies += [ |
| 148 |
wayland_client, |
| 149 |
dependency('wayland-egl'), |
| 150 |
dependency('xkbcommon') |
| 151 |
] |
| 152 |
|
| 153 |
sources += [ |
| 154 |
'egl_context.c', |
| 155 |
'osmesa_context.c', |
| 156 |
'posix_thread.c', |
| 157 |
'posix_time.c', |
| 158 |
'posix_poll.c', |
| 159 |
'posix_module.c', |
| 160 |
'wl_init.c', |
| 161 |
'wl_monitor.c', |
| 162 |
'wl_window.c', |
| 163 |
'xkb_unicode.c', |
| 164 |
'xkb_unicode.h', |
| 165 |
] + wl_protos_src + wl_protos_headers |
| 166 |
elif backend == 'osmesa' |
| 167 |
dependencies += dependency('osmesa') |
| 168 |
sources += [ |
| 169 |
'null_init.c', |
| 170 |
'null_joystick.c', |
| 171 |
'null_monitor.c', |
| 172 |
'null_window.c', |
| 173 |
'osmesa_context.c', |
| 174 |
'posix_thread.c', |
| 175 |
'posix_time.c', |
| 176 |
] |
| 177 |
endif |
| 178 |
|
| 179 |
include = [include_directories('../include'), include_directories('.')] |
| 180 |
|
| 181 |
glfw3_library = library( |
| 182 |
'glfw', |
| 183 |
sources, |
| 184 |
version: meson.project_version(), |
| 185 |
c_args: ['-D_GLFW_USE_CONFIG_H'], |
| 186 |
objc_args: ['-D_GLFW_USE_CONFIG_H'], |
| 187 |
dependencies: dependencies, |
| 188 |
include_directories: include, |
| 189 |
) |
| 190 |
|
| 191 |
glfw3_dep = declare_dependency( |
| 192 |
link_with: [glfw3_library], |
| 193 |
include_directories: include, |
| 194 |
dependencies: dependencies, |
| 195 |
) |
| 196 |
|
| 197 |
meson.override_dependency('glfw3', glfw3_dep) |