Commit 064aef35 authored by Drew DeVault's avatar Drew DeVault Committed by Jakob Bornecrantz
Browse files

build: port to meson

parent c6586cfd
This diff is collapsed.
# Copyright 2018-2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
doxyconf = configuration_data()
doxyconf.set('SRCDIR', meson.source_root())
doxyconf.set('BUILDDIR', meson.build_root())
doxyconf.set('CURBUILDDIR', meson.current_build_dir())
if get_option('doxygen-warn-undocumented') and get_option('doxygen-extract-all')
error('doxygen-warn-undocumented and doxygen-extract-all are mutually incompatible')
endif
if get_option('doxygen-warn-undocumented')
doxyconf.set('DOXYGEN_WARN_UNDOCUMENTED', 'YES')
else
doxyconf.set('DOXYGEN_WARN_UNDOCUMENTED', 'NO')
endif
if get_option('doxygen-extract-all')
doxyconf.set('DOXYGEN_EXTRACT_ALL', 'YES')
else
doxyconf.set('DOXYGEN_EXTRACT_ALL', 'NO')
endif
doxyfile = configure_file(input: 'Doxyfile.meson.in',
output: 'Doxyfile', configuration: doxyconf, install: false)
html = custom_target('docs',
input: doxyfile, output: 'html', command: [doxygen, doxyfile],
build_by_default: true)
# Copyright 2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
project(
'xrt',
['c', 'cpp'],
version: '0.1.0',
license: 'BSL-1.0',
meson_version: '>=0.49.0',
default_options: [
'c_std=c11',
'warning_level=2',
],
)
cc = meson.get_compiler('c')
cpp = meson.get_compiler('cpp')
add_project_arguments(cc.get_supported_arguments([
'-D_XOPEN_SOURCE=700',
'-pedantic',
'-Wall',
'-Wextra',
'-Wno-unused-parameter',
]), language: 'c')
add_project_arguments(cpp.get_supported_arguments([
'-D_XOPEN_SOURCE=700',
'-Wall',
'-Wextra',
'-Wno-unused-parameter',
'-Wno-deprecated-copy', # Eigen
]), language: 'cpp')
glslangValidator = find_program('glslangValidator')
avcodec = dependency('libavcodec', required: false)
eigen3 = dependency('eigen3')
libjpeg = dependency('libjpeg', required: false)
libusb = dependency('libusb-1.0', required: false)
opencv = dependency('opencv4', required: get_option('tracking'))
opengl = dependency('gl')
sdl2 = dependency('sdl2', required: get_option('gui'))
udev = dependency('libudev', required: false)
libuvc = dependency('libuvc', required: false)
vulkan = dependency('vulkan')
doxygen = find_program('doxygen', required: get_option('docs'))
pthreads = cc.find_library('pthread', required: true)
if get_option('tracking').enabled() or get_option('tracking').auto()
build_tracking = opencv.found()
else
build_tracking = false
endif
# TODO: make these behave well when not present
x11 = dependency('x11', required: false)
xcb = dependency('xcb', required: false)
xcb_randr = dependency('xcb-randr', required: false)
wayland = dependency('wayland-client', required: false)
hidapi_required = false
openhmd_required = false
v4l2_required = false
drivers = get_option('drivers')
if 'ohmd' in drivers
openhmd_required = true
endif
if 'hdk' in drivers or 'psvr' in drivers
hidapi_required = true
endif
if 'v4l2' in drivers
v4l2_required = true
endif
if 'auto' in drivers
drivers += ['psmv', 'hydra']
endif
openhmd = dependency('openhmd', required: openhmd_required)
hidapi = dependency('hidapi', required: hidapi_required)
v4l2 = dependency('libv4l2', required: v4l2_required)
if openhmd.found() and ('auto' in drivers or 'ohmd' in drivers)
if 'ohmd' not in drivers
drivers += ['ohmd']
endif
endif
if hidapi.found() and ('auto' in drivers or 'psvr' in drivers or 'hdk' in drivers)
if 'psvr' not in drivers
drivers += ['psvr']
endif
if 'hdk' not in drivers
drivers += ['hdk']
endif
endif
if v4l2.found() and ('auto' in drivers or 'v4l2' in drivers)
if 'v4l2' not in drivers
drivers += ['v4l2']
endif
endif
if drivers.length() == 0 or drivers == ['auto']
error('You must enable at least one driver.')
else
message('Building with drivers ' + ', '.join(drivers))
endif
if udev.found()
add_project_arguments('-DXRT_HAVE_LIBUDEV', language: ['c', 'cpp'])
endif
if libusb.found()
add_project_arguments('-DXRT_HAVE_LIBUSB', language: ['c', 'cpp'])
endif
if opencv.found()
add_project_arguments('-DXRT_HAVE_OPENCV', language: ['c', 'cpp'])
endif
if libjpeg.found()
add_project_arguments('-DXRT_HAVE_JPEG', language: ['c', 'cpp'])
endif
if libuvc.found()
add_project_arguments('-DXRT_HAVE_LIBUVC', language: ['c', 'cpp'])
endif
if avcodec.found()
add_project_arguments('-DXRT_HAVE_FFMPEG', language: ['c', 'cpp'])
endif
if sdl2.found()
add_project_arguments('-DXRT_HAVE_SDL2', language: ['c', 'cpp'])
endif
subdir('src')
if doxygen.found()
subdir('doc')
endif
# This is here so that it gets emitted in the top-level build directory
manifest_devconf = configuration_data()
# https://github.com/mesonbuild/meson/issues/5940
manifest_devconf.set('runtime_path', openxr.full_path())
manifest_dev_json = configure_file(
input: manifest_in,
output: 'openxr_monado-dev.json',
configuration: manifest_devconf,
)
# Copyright 2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
option('drivers',
type: 'array',
choices: ['auto', 'hdk', 'hydra', 'ohmd', 'psmv', 'psvr', 'v4l2'],
value: ['auto'],
description: 'Set of drivers to build')
option('docs',
type: 'feature',
value: 'auto',
description: 'Build the documentation')
option('doxygen-warn-undocumented',
type: 'boolean',
value: false,
description: 'Configure doxygen to emit warnings for undocumented entities')
option('doxygen-extract-all',
type: 'boolean',
value: false,
description: 'Extract all entities for documentation, not just documented ones')
option('gui',
type: 'feature',
value: 'auto',
description: 'Enable GUI')
option('tracking',
type: 'feature',
value: 'auto',
description: 'Enable tracking support')
option('vulkan-validation',
type: 'boolean',
value: true,
description: 'Enable Vulkan validation for compositor')
option('install-active-runtime',
type: 'boolean',
value: true,
description: 'Make Monado the default OpenXR runtime on install')
# Copyright 2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
configure_file(targets_enabled_drivers.h.cmake_in ${CMAKE_CURRENT_BINARY_DIR}/targets_enabled_drivers.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory(xrt)
external_include = include_directories('.')
# Copyright 2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
conf_data = configuration_data()
conf_data.set('XRT_BUILD_OHMD', 'ohmd' in drivers)
conf_data.set('XRT_BUILD_HDK', 'hdk' in drivers)
conf_data.set('XRT_BUILD_PSMV', 'psmv' in drivers)
conf_data.set('XRT_BUILD_PSVR', 'psvr' in drivers)
targets_enabled_h = configure_file(
input: 'targets_enabled_drivers.h.meson_in',
output: 'targets_enabled_drivers.h',
configuration: conf_data,
)
targets_enabled = declare_dependency(
sources: targets_enabled_h,
include_directories: include_directories('.'),
)
subdir('external')
subdir('xrt')
// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Generated header listing the drivers available
*/
#pragma once
#mesondefine XRT_BUILD_OHMD
#mesondefine XRT_BUILD_HDK
#mesondefine XRT_BUILD_PSMV
#mesondefine XRT_BUILD_PSVR
# Copyright 2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
aux_include = include_directories('.')
lib_aux_util = static_library(
'aux_util',
files(
'util/u_misc.c',
'util/u_misc.h',
'util/u_debug.c',
'util/u_debug.h',
'util/u_device.c',
'util/u_device.h',
'util/u_documentation.h',
'util/u_format.c',
'util/u_format.h',
'util/u_frame.c',
'util/u_frame.h',
'util/u_hashmap.cpp',
'util/u_hashmap.h',
'util/u_hashset.cpp',
'util/u_hashset.h',
'util/u_sink.h',
'util/u_sink_converter.c',
'util/u_sink_queue.c',
'util/u_sink_split.c',
'util/u_time.cpp',
'util/u_time.h',
'util/u_var.cpp',
'util/u_var.h',
),
include_directories: xrt_include,
)
aux_util = declare_dependency(
include_directories: aux_include,
link_whole: lib_aux_util,
)
lib_aux_os = static_library(
'aux_os',
files(
'os/os_documentation.h',
'os/os_hid.h',
'os/os_hid_hidraw.c',
'os/os_threading.h',
'os/os_time.h',
),
include_directories: xrt_include,
)
aux_os = declare_dependency(
include_directories: aux_include,
link_whole: lib_aux_os,
)
lib_aux_math = static_library(
'aux_math',
files(
'math/m_api.h',
'math/m_base.cpp',
'math/m_eigen_interop.h',
'math/m_hash.cpp',
'math/m_optics.c',
'math/m_quatexpmap.cpp',
),
include_directories: xrt_include,
dependencies: [eigen3],
)
aux_math = declare_dependency(
include_directories: aux_include,
link_whole: lib_aux_math,
)
tracking_srcs = [
'tracking/t_calibration.cpp',
'tracking/t_convert.cpp',
'tracking/t_debug_hsv_filter.cpp',
'tracking/t_debug_hsv_picker.cpp',
'tracking/t_debug_hsv_viewer.cpp',
'tracking/t_hsv_filter.c',
'tracking/t_tracking.h',
]
if 'psmv' in drivers
tracking_srcs += ['tracking/t_tracker_psmv.cpp']
endif
if 'psvr' in drivers
tracking_srcs += ['tracking/t_tracker_psvr.cpp']
endif
lib_aux_tracking = static_library(
'aux_tracking',
files(tracking_srcs),
include_directories: xrt_include,
dependencies: [eigen3, opencv],
build_by_default: build_tracking,
)
aux_tracking = declare_dependency(
include_directories: aux_include,
link_whole: lib_aux_tracking,
)
all_aux = [aux_util, aux_os, aux_math]
if build_tracking
all_aux += [aux_tracking]
endif
aux = declare_dependency(dependencies: all_aux)
# Copyright 2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
subdir('shaders')
compositor_deps = [aux, shaders, vulkan]
compositor_srcs = [
'client/comp_gl_api.c',
'client/comp_gl_api.h',
'client/comp_gl_client.c',
'client/comp_gl_client.h',
'client/comp_vk_client.c',
'client/comp_vk_client.h',
'client/comp_xlib_client.c',
'common/comp_vk.c',
'common/comp_vk.h',
'common/comp_vk_swapchain.h',
'common/comp_vk_swapchain.c',
'main/comp_client_interface.h',
'main/comp_compositor.c',
'main/comp_compositor.h',
'main/comp_distortion.c',
'main/comp_distortion.h',
'main/comp_documentation.h',
'main/comp_glue_gl.c',
'main/comp_glue_vk.c',
'main/comp_glue_xlib.c',
'main/comp_renderer.c',
'main/comp_renderer.h',
'main/comp_settings.c',
'main/comp_settings.h',
'main/comp_swapchain.c',
'main/comp_window.h',
]
compile_args = []
if xcb.found()
compile_args += ['-DVK_USE_PLATFORM_XCB_KHR']
compositor_srcs += ['main/comp_window_xcb.cpp']
compositor_deps += [xcb]
endif
if xcb_randr.found()
# TODO: monado doesn't compile when xcb is present but not xrandr
compile_args += ['-DVK_USE_PLATFORM_XLIB_XRANDR_EXT']
compositor_srcs += ['main/comp_window_direct_mode.cpp']
compositor_deps += [xcb_randr]
endif
# TODO: This backend is straight-up broken
#if wayland.found()
# compile_args += ['-DVK_USE_PLATFORM_WAYLAND_KHR']
# compositor_srcs += ['main/comp_window_wayland.cpp']
# compositor_deps += [wayland]
#endif
if get_option('vulkan-validation')
compile_args += ['-DXRT_ENABLE_VK_VALIDATION']
endif
lib_comp = static_library(
'comp',
compositor_srcs,
include_directories: [
xrt_include,
external_include,
],
dependencies: compositor_deps,
c_args: compile_args,
cpp_args: compile_args,
)
shader_srcs = [
'distortion.vert',
'none.frag',
'panotools.frag',
'vive.frag',
]
shader_headers = []
foreach shader : shader_srcs
header_out = shader + '.h'
shader_headers += custom_target(
header_out,
command: [
glslangValidator,
'-V', '@INPUT@',
'-o', '@OUTPUT@',
'--vn', 'shaders_' + shader.underscorify(),
],
input: shader,
output: header_out,
)
endforeach
shaders = declare_dependency(
include_directories: include_directories('..'),
sources: shader_headers,
)
# Copyright 2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
drv_include = include_directories('.')
lib_drv_hdk = static_library(
'drv_hdk',
files(
'hdk/hdk_device.cpp',
'hdk/hdk_device.h',
'hdk/hdk_interface.h',
'hdk/hdk_prober.c',
),
include_directories: xrt_include,
dependencies: [aux, hidapi],
build_by_default: 'hdk' in drivers,
)
lib_drv_hydra = static_library(
'drv_hydra',
files(
'hydra/hydra_driver.c',
'hydra/hydra_interface.h',
),
include_directories: xrt_include,
dependencies: [aux],
build_by_default: 'hydra' in drivers,
)
lib_drv_ohmd = static_library(
'drv_ohmd',
files(
'ohmd/oh_device.c',
'ohmd/oh_device.h',
'ohmd/oh_interface.h',
'ohmd/oh_prober.c',
),
include_directories: xrt_include,
dependencies: [aux, openhmd],
build_by_default: 'ohmd' in drivers,
)
lib_drv_psmv = static_library(
'drv_psmv',
files(
'psmv/psmv_driver.c',
'psmv/psmv_interface.h',
),
include_directories: xrt_include,
dependencies: [aux],
build_by_default: 'psmv' in drivers,
)
lib_drv_psvr = static_library(
'drv_psvr',
files(
'psvr/psvr_device.c',
'psvr/psvr_device.h',
'psvr/psvr_interface.h',
'psvr/psvr_packet.c',
'psvr/psvr_prober.c',
),
include_directories: xrt_include,
dependencies: [aux, hidapi],
build_by_default: 'psvr' in drivers,
)
lib_drv_v4l2 = static_library(
'drv_v4l2',
files(
'v4l2/v4l2_driver.c',
),
include_directories: xrt_include,
dependencies: [aux, v4l2],
build_by_default: 'v4l2' in drivers,
)
# Copyright 2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
xrt_include = include_directories('include')
subdir('auxiliary')
subdir('drivers')
subdir('compositor')
subdir('state_trackers')
subdir('targets')
# Copyright 2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
subdir('oxr')
subdir('prober')
# Copyright 2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
lib_st_oxr = static_library(
'st_oxr',
files(
'oxr_api_action.c',
'oxr_api_funcs.h',
'oxr_api_instance.c',
'oxr_api_negotiate.c',
'oxr_api_session.c',
'oxr_api_space.c',
'oxr_api_swapchain.c',
'oxr_api_system.c',
'oxr_api_verify.h',
'oxr_binding.c',
'oxr_chain.h',
'oxr_event.cpp',
'oxr_extension_support.h',
'oxr_handle_base.c',
'oxr_input.c',
'oxr_instance.c',
'oxr_logger.cpp',
'oxr_logger.h',
'oxr_objects.h',
'oxr_path.c',
'oxr_session.c',
'oxr_session_gl.c',
'oxr_session_vk.c',
'oxr_space.c',
'oxr_swapchain.c',
'oxr_swapchain_gl.c',
'oxr_swapchain_vk.c',
'oxr_system.c',
'oxr_two_call.h',
'oxr_verify.cpp',
'oxr_vulkan.c',
'oxr_xdev.c',
),
include_directories: [
xrt_include,
external_include,
],
dependencies: [aux, vulkan],
)
# Copyright 2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
prober_sources = [