From 8b01fbefd9f314c9b2d5c0ca4be337062469f9cd Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Wed, 11 Jan 2023 20:26:00 +0000 Subject: [PATCH] build: Use openvr_api as subproject --- .github/workflows/main.yml | 2 +- meson.build | 24 ++++++++++++++---------- meson_options.txt | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index abb2dfe..5043151 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: pacman -S --noconfirm git meson clang glslang libcap wlroots \ sdl2 vulkan-headers libx11 libxcomposite libxrender libxres \ libxtst libxkbcommon libdrm libinput wayland-protocols \ - xorg-xwayland pipewire + xorg-xwayland pipewire cmake - uses: actions/checkout@v2 with: submodules: recursive diff --git a/meson.build b/meson.build index 68a3f44..e45b558 100644 --- a/meson.build +++ b/meson.build @@ -35,20 +35,24 @@ hwdata_dep = dependency('hwdata') dep_x11 = dependency('x11') vulkan_dep = dependency('vulkan') -cpu_family = target_machine.cpu_family() -openvr_path_base = meson.source_root() + '/subprojects/openvr' -openvr_lib_path_base = openvr_path_base + '/lib' -if (cpu_family == 'x86_64') - openvr_lib_path = openvr_lib_path_base +'/linux64' -elif (cpu_family == 'x86') - openvr_lib_path = openvr_lib_path_base +'/linux32' -elif (cpu_family == 'aarch64') - openvr_lib_path = openvr_lib_path_base +'/linuxarm64' +if get_option('enable_openvr_support') + openvr_dep = dependency('openvr_api', required : false) + if not openvr_dep.found() + cmake = import('cmake') + openvr_var = cmake.subproject_options() + openvr_var.add_cmake_defines({'USE_LIBCXX': false}) + openvr_var.set_override_option('warning_level', '0') + openvr_proj = cmake.subproject('openvr', options : openvr_var) + openvr_dep = openvr_proj.dependency('openvr_api') + endif +else + # null dep + openvr_dep = dependency('', required : false) endif -openvr_dep = cppc.find_library('openvr_api', dirs: openvr_lib_path, required : get_option('openvr')) add_project_arguments( '-DHAVE_PIPEWIRE=@0@'.format(pipewire_dep.found().to_int()), + '-DHAVE_OPENVR=@0@'.format(openvr_dep.found().to_int()), '-DHWDATA_PNP_IDS="@0@"'.format(hwdata_dep.get_variable('pkgdatadir') / 'pnp.ids'), language: 'cpp', ) diff --git a/meson_options.txt b/meson_options.txt index 1daefda..8075f3e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,4 +1,4 @@ option('pipewire', type: 'feature', description: 'Screen capture via PipeWire') option('enable_gamescope', type : 'boolean', value : true, description: 'Build Gamescope executable') option('enable_gamescope_wsi_layer', type : 'boolean', value : true, description: 'Build Gamescope layer') -option('openvr', type : 'feature', description: 'SteamVR Integrations') +option('enable_openvr_support', type : 'boolean', value : true, description: 'OpenVR Integrations')