build: Adjust meson build equivalently

This commit is contained in:
Ryan Pavlik 2020-01-14 12:21:23 -06:00
parent 066f57d7d8
commit 871395d5b5
5 changed files with 119 additions and 35 deletions

View file

@ -57,16 +57,16 @@ glslangValidator = find_program('glslangValidator')
pthreads = cc.find_library('pthread', required: true) pthreads = cc.find_library('pthread', required: true)
avcodec = dependency('libavcodec', required: false) avcodec = dependency('libavcodec', required: false)
egl = dependency('egl') egl = dependency('egl', required: get_option('egl'))
egl = egl.partial_dependency(includes: true) egl = egl.partial_dependency(includes: true)
eigen3 = dependency('eigen3') eigen3 = dependency('eigen3')
libjpeg = dependency('libjpeg', required: false) libjpeg = dependency('libjpeg', required: false)
libusb = dependency('libusb-1.0', required: false) libusb = dependency('libusb-1.0', required: false)
opengl = dependency('gl') opengl = dependency('gl', required: get_option('opengl'))
sdl2 = dependency('sdl2', required: get_option('gui')) sdl2 = dependency('sdl2', required: get_option('gui'))
udev = dependency('libudev', required: false) udev = dependency('libudev', required: false)
libuvc = dependency('libuvc', required: false) libuvc = dependency('libuvc', required: false)
vulkan = dependency('vulkan') vulkan = dependency('vulkan', required: true)
zlib = dependency('zlib', required: false) zlib = dependency('zlib', required: false)
opencv = dependency('opencv4', required: false) opencv = dependency('opencv4', required: false)
@ -79,13 +79,13 @@ if get_option('tracking').enabled() or get_option('tracking').auto()
endif endif
# TODO: make these behave well when not present # TODO: make these behave well when not present
x11 = dependency('x11', required: false) x11 = dependency('x11', required: get_option('xlib'))
xcb = dependency('xcb', required: false) xcb = dependency('xcb', required: get_option('xcb'))
xcb_randr = dependency('xcb-randr', required: false) xcb_randr = dependency('xcb-randr', required: get_option('xcb'))
wayland = dependency('wayland-client', required: false) wayland = dependency('wayland-client', required: get_option('wayland'))
wayland_protos = dependency('wayland-protocols', required: false) wayland_protos = dependency('wayland-protocols', required: get_option('wayland'))
wayland_scanner = dependency('wayland-scanner', required: false) wayland_scanner = dependency('wayland-scanner', required: get_option('wayland'))
if wayland_scanner.found() if wayland_scanner.found()
wayland_scanner = find_program( wayland_scanner = find_program(
@ -94,6 +94,34 @@ if wayland_scanner.found()
) )
endif endif
build_opengl = false
if get_option('opengl').enabled() or get_option('opengl').auto()
build_opengl = opengl.found()
endif
build_egl = false
if get_option('egl').enabled() or get_option('egl').auto()
build_egl = opengl.found() and egl.found()
endif
build_xlib = false
if get_option('xlib').enabled() or get_option('xlib').auto()
build_xlib = x11.found()
endif
build_xcb = false
if get_option('xcb').enabled() or get_option('xcb').auto()
build_xcb = xcb.found()
endif
build_xcb_xrandr_direct = build_xcb and build_xlib and xcb_randr.found()
build_wayland = false
if get_option('wayland').enabled() or get_option('wayland').auto()
build_wayland = wayland.found() and wayland_protos.found() and wayland_scanner.found()
endif
# For now required on Linux # For now required on Linux
if target_machine.system() == 'linux' if target_machine.system() == 'linux'
v4l2_required = true v4l2_required = true

View file

@ -41,3 +41,28 @@ option('install-active-runtime',
type: 'boolean', type: 'boolean',
value: true, value: true,
description: 'Make Monado the default OpenXR runtime on install') description: 'Make Monado the default OpenXR runtime on install')
option('opengl',
type: 'feature',
value: 'auto',
description: 'Enable OpenGL/GLES application support.')
option('egl',
type: 'feature',
value: 'auto',
description: 'Enable EGL application support.')
option('xlib',
type: 'feature',
value: 'auto',
description: 'Enable xlib application support. Also required for direct mode on X.')
option('xcb',
type: 'feature',
value: 'auto',
description: 'Enable xcb support for direct mode on X.')
option('wayland',
type: 'feature',
value: 'auto',
description: 'Enable support for Wayland rendering.')

View file

@ -7,11 +7,8 @@ subdir('shaders')
compositor_deps = [aux, shaders, vulkan] compositor_deps = [aux, shaders, vulkan]
compositor_srcs = [ compositor_srcs = [
'client/comp_gl_client.c',
'client/comp_gl_client.h',
'client/comp_vk_client.c', 'client/comp_vk_client.c',
'client/comp_vk_client.h', 'client/comp_vk_client.h',
'client/comp_gl_xlib_client.c',
'common/comp_vk.c', 'common/comp_vk.c',
'common/comp_vk.h', 'common/comp_vk.h',
'common/comp_vk_swapchain.h', 'common/comp_vk_swapchain.h',
@ -22,10 +19,6 @@ compositor_srcs = [
'main/comp_distortion.c', 'main/comp_distortion.c',
'main/comp_distortion.h', 'main/comp_distortion.h',
'main/comp_documentation.h', 'main/comp_documentation.h',
'main/comp_glue_egl.c',
'main/comp_glue_gl.c',
'main/comp_glue_gles.c',
'main/comp_glue_gl_xlib.c',
'main/comp_glue_vk.c', 'main/comp_glue_vk.c',
'main/comp_renderer.c', 'main/comp_renderer.c',
'main/comp_renderer.h', 'main/comp_renderer.h',
@ -37,20 +30,44 @@ compositor_srcs = [
compile_args = [] compile_args = []
if xcb.found() if build_xcb
compile_args += ['-DVK_USE_PLATFORM_XCB_KHR'] compile_args += ['-DVK_USE_PLATFORM_XCB_KHR']
compositor_srcs += ['main/comp_window_xcb.cpp'] compositor_srcs += ['main/comp_window_xcb.cpp']
compositor_deps += [xcb] compositor_deps += [xcb]
endif endif
if xcb_randr.found() if build_xcb_xrandr_direct
# TODO: monado doesn't compile when xcb is present but not xrandr
compile_args += ['-DVK_USE_PLATFORM_XLIB_XRANDR_EXT'] compile_args += ['-DVK_USE_PLATFORM_XLIB_XRANDR_EXT']
compositor_srcs += ['main/comp_window_direct_mode.cpp'] compositor_srcs += ['main/comp_window_direct_mode.cpp']
compositor_deps += [xcb_randr] compositor_deps += [xcb_randr]
endif endif
if wayland.found() and wayland_protos.found() and wayland_scanner.found() if build_opengl
compositor_srcs += [
'client/comp_gl_client.c',
'client/comp_gl_client.h',
'main/comp_glue_gl.c',
'main/comp_glue_gles.c',
]
compositor_deps += [opengl]
endif
if build_opengl and build_xlib
compositor_srcs += [
'client/comp_gl_xlib_client.c',
'main/comp_glue_gl_xlib.c',
]
compositor_deps += [x11]
endif
if build_egl
compositor_srcs += [
'main/comp_glue_egl.c',
]
compositor_deps += [egl]
endif
if build_wayland
wl_protos_src = [] wl_protos_src = []
wl_protos_headers = [] wl_protos_headers = []
wl_protocol_dir = wayland_protos.get_pkgconfig_variable('pkgdatadir') wl_protocol_dir = wayland_protos.get_pkgconfig_variable('pkgdatadir')

View file

@ -2,15 +2,15 @@
# SPDX-License-Identifier: BSL-1.0 # SPDX-License-Identifier: BSL-1.0
compile_args = [] compile_args = []
if x11.found() if build_opengl
compile_args += ['-DXR_USE_GRAPHICS_API_OPENGL', '-DXR_USE_GRAPHICS_API_OPENGL_ES'] compile_args += ['-DXR_USE_GRAPHICS_API_OPENGL', '-DXR_USE_GRAPHICS_API_OPENGL_ES']
endif endif
if egl.found() if build_egl
compile_args += ['-DXR_USE_PLATFORM_EGL'] compile_args += ['-DXR_USE_PLATFORM_EGL']
endif endif
if opengl.found() if build_xlib
compile_args += ['-DXR_USE_PLATFORM_XLIB'] compile_args += ['-DXR_USE_PLATFORM_XLIB']
endif endif

View file

@ -37,6 +37,31 @@ else
hack_src += 'oxr_sdl2_hack.c' hack_src += 'oxr_sdl2_hack.c'
endif endif
openxr_deps = [
libusb,
libuvc,
pthreads,
targets_enabled,
udev,
vulkan,
]
if build_opengl
openxr_deps += [opengl]
endif
if build_opengl and build_xlib
openxr_deps += [x11]
endif
if build_xcb
openxr_deps += [xcb]
endif
if build_xcb_xrandr_direct
openxr_deps += [xcb_randr]
endif
openxr = library( openxr = library(
runtime_target, runtime_target,
files( files(
@ -61,18 +86,7 @@ openxr = library(
drv_include, drv_include,
xrt_include, xrt_include,
] + hack_incs, ] + hack_incs,
dependencies: [ dependencies: openxr_deps + driver_deps + hack_deps,
libusb,
libuvc,
opengl,
pthreads,
targets_enabled,
udev,
vulkan,
x11,
xcb,
xcb_randr,
] + driver_deps + hack_deps,
install: true, install: true,
) )