opencomposite: init at unstable-2023-07-02

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>

+193
+112
pkgs/development/libraries/opencomposite/cmake-use-find_package-where-needed.patch
···
··· 1 + From 5430196765402655715f759e3de0166ad3fbe1fe Mon Sep 17 00:00:00 2001 2 + From: Sefa Eyeoglu <contact@scrumplex.net> 3 + Date: Fri, 28 Jul 2023 12:26:58 +0200 4 + Subject: [PATCH] cmake: use find_package where needed 5 + 6 + Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net> 7 + --- 8 + CMakeLists.txt | 62 ++++---------------------------------------------- 9 + 1 file changed, 4 insertions(+), 58 deletions(-) 10 + 11 + diff --git a/CMakeLists.txt b/CMakeLists.txt 12 + index bb3c49a..e9d6d56 100644 13 + --- a/CMakeLists.txt 14 + +++ b/CMakeLists.txt 15 + @@ -98,66 +98,13 @@ endif () 16 + # === OpenXR === 17 + # Building CMake subprojects is a real pain (IMO), so just build this here 18 + 19 + -set(XrDir libs/openxr-sdk) 20 + -set(XrDirLoader libs/openxr-sdk/src/loader) 21 + -set(XrDirCommon libs/openxr-sdk/src/common) 22 + -if (ANDROID) 23 + - # Whatever consumes this library must then link to an OpenXR loader, such as the Oculus one 24 + - add_library(OpenXR STATIC scripts/empty.c) # Doesn't do anything 25 + -else () 26 + -add_library(OpenXR STATIC 27 + - ${XrDirLoader}/api_layer_interface.cpp 28 + - ${XrDirLoader}/api_layer_interface.hpp 29 + - ${XrDirLoader}/loader_core.cpp 30 + - ${XrDirLoader}/loader_instance.cpp 31 + - ${XrDirLoader}/loader_instance.hpp 32 + - ${XrDirLoader}/loader_logger.cpp 33 + - ${XrDirLoader}/loader_logger.hpp 34 + - ${XrDirLoader}/loader_logger_recorders.cpp 35 + - ${XrDirLoader}/loader_logger_recorders.hpp 36 + - ${XrDirLoader}/manifest_file.cpp 37 + - ${XrDirLoader}/manifest_file.hpp 38 + - ${XrDirLoader}/runtime_interface.cpp 39 + - ${XrDirLoader}/runtime_interface.hpp 40 + - 41 + - ${XrDirLoader}/xr_generated_loader.hpp 42 + - ${XrDirLoader}/xr_generated_loader.cpp 43 + - ${XrDir}/src/xr_generated_dispatch_table.h 44 + - ${XrDir}/src/xr_generated_dispatch_table.c 45 + - 46 + - ${XrDirCommon}/filesystem_utils.cpp 47 + - ${XrDirCommon}/object_info.cpp 48 + - 49 + - ${XrDir}/src/external/jsoncpp/src/lib_json/json_reader.cpp 50 + - ${XrDir}/src/external/jsoncpp/src/lib_json/json_value.cpp 51 + - ${XrDir}/src/external/jsoncpp/src/lib_json/json_writer.cpp 52 + -) 53 + -endif() 54 + -target_include_directories(OpenXR PRIVATE ${XrDirCommon} ${XrDir}/src ${XrDir}/src/external/jsoncpp/include) 55 + -target_include_directories(OpenXR PUBLIC ${XrDir}/include) 56 + -# Platform-dependent flags 57 + -if (WIN32) 58 + - target_compile_definitions(OpenXR PRIVATE -DXR_OS_WINDOWS -DXR_USE_PLATFORM_WIN32 59 + - -DXR_USE_GRAPHICS_API_D3D11 -DXR_USE_GRAPHICS_API_D3D12 -DXR_USE_GRAPHICS_API_OPENGL) 60 + - target_link_libraries(OpenXR PUBLIC advapi32 pathcch OpenGL32) 61 + -else() 62 + - # TODO Turtle1331 should we include -DXR_USE_PLATFORM_(XLIB|XCB|WAYLAND) here? 63 + - target_compile_definitions(OpenXR PRIVATE -DXR_OS_LINUX 64 + - -DXR_USE_GRAPHICS_API_OPENGL -DXR_USE_GRAPHICS_API_VULKAN) 65 + - target_link_libraries(OpenXR PUBLIC -ldl) 66 + -endif() 67 + -target_link_libraries(OpenXR PUBLIC Vulkan) 68 + - 69 + -if (ANDROID) 70 + - target_compile_definitions(OpenXR PUBLIC -DXR_USE_PLATFORM_ANDROID -DXR_USE_GRAPHICS_API_OPENGL_ES) 71 + -endif() 72 + +find_package(OpenXR REQUIRED) 73 + 74 + # === glm === 75 + # Since we used to use LibOVR's maths library, we need a replacement 76 + # glm is an obvious choice 77 + 78 + -add_library(glm INTERFACE) 79 + -target_include_directories(glm INTERFACE libs/glm) # No separate include directory :( 80 + +find_package(glm REQUIRED) 81 + 82 + # === DrvOpenXR === 83 + add_library(DrvOpenXR STATIC 84 + @@ -189,7 +136,7 @@ add_library(DrvOpenXR STATIC 85 + ) 86 + target_include_directories(DrvOpenXR PUBLIC DrvOpenXR/pub ${CMAKE_BINARY_DIR}) 87 + target_include_directories(DrvOpenXR PRIVATE DrvOpenXR OpenOVR) 88 + -target_link_libraries(DrvOpenXR PUBLIC OpenVR OpenXR glm) 89 + +target_link_libraries(DrvOpenXR PUBLIC OpenVR OpenXR::openxr_loader glm::glm) 90 + target_compile_definitions(DrvOpenXR PRIVATE ${GRAPHICS_API_SUPPORT_FLAGS} -D_CRT_SECURE_NO_WARNINGS) 91 + source_group(Public REGULAR_EXPRESSION DrvOpenXR/pub/*) 92 + 93 + @@ -357,7 +304,7 @@ target_include_directories(OCCore PUBLIC OpenOVR ${CMAKE_BINARY_DIR}) # TODO ma 94 + target_include_directories(OCCore PRIVATE BundledLibs OpenVRHeaders) 95 + target_compile_definitions(OCCore PRIVATE ${GRAPHICS_API_SUPPORT_FLAGS}) 96 + 97 + -target_link_libraries(OCCore OpenVR OpenXR Vulkan glm) 98 + +target_link_libraries(OCCore OpenVR OpenXR::openxr_loader Vulkan glm::glm) 99 + 100 + if (NOT WIN32 AND NOT ANDROID) 101 + find_package(OpenGL REQUIRED) # for glGetError() 102 + @@ -411,7 +358,6 @@ endif () 103 + if (WIN32) 104 + else () 105 + target_compile_options(DrvOpenXR PRIVATE -fPIC) 106 + - target_compile_options(OpenXR PRIVATE -fPIC) 107 + target_compile_options(OCCore PRIVATE -fPIC) 108 + endif () 109 + 110 + -- 111 + 2.41.0 112 +
+59
pkgs/development/libraries/opencomposite/default.nix
···
··· 1 + { lib 2 + , stdenv 3 + , fetchFromGitLab 4 + 5 + , cmake 6 + 7 + , glm 8 + , libGL 9 + , openxr-loader 10 + , python3 11 + , vulkan-headers 12 + , vulkan-loader 13 + , xorg 14 + }: 15 + 16 + stdenv.mkDerivation { 17 + pname = "opencomposite"; 18 + version = "unstable-2023-07-02"; 19 + 20 + src = fetchFromGitLab { 21 + owner = "znixian"; 22 + repo = "OpenOVR"; 23 + rev = "a59b16204a1ee61a59413667a516375071a113f0"; 24 + hash = "sha256-JSVd/+A/WldP+A2vOOG4lbwb4QCE/PymEm4VbjUxWrw="; 25 + }; 26 + 27 + patches = [ 28 + # Force OpenComposite to use our OpenXR and glm, instead of its Git submodules 29 + ./cmake-use-find_package-where-needed.patch 30 + ]; 31 + 32 + nativeBuildInputs = [ 33 + cmake 34 + ]; 35 + 36 + buildInputs = [ 37 + glm 38 + libGL 39 + openxr-loader 40 + python3 41 + vulkan-headers 42 + vulkan-loader 43 + xorg.libX11 44 + ]; 45 + 46 + installPhase = '' 47 + runHook preInstall 48 + mkdir -p $out/lib/opencomposite 49 + cp -r bin/ $out/lib/opencomposite 50 + runHook postInstall 51 + ''; 52 + 53 + meta = with lib; { 54 + description = "Reimplementation of OpenVR, translating calls to OpenXR"; 55 + homepage = "https://gitlab.com/znixian/OpenOVR"; 56 + license = with licenses; [ gpl3Only ]; 57 + maintainers = with maintainers; [ Scrumplex ]; 58 + }; 59 + }
+18
pkgs/development/libraries/opencomposite/helper.nix
···
··· 1 + { writeShellApplication 2 + 3 + , monado 4 + , opencomposite 5 + }: 6 + writeShellApplication { 7 + name = "opencomposite-helper"; 8 + text = '' 9 + # Tell Proton to use OpenComposite instead of OpenVR 10 + export VR_OVERRIDE=${opencomposite}/lib/opencomposite 11 + # Help OpenComposite find the OpenXR runtime 12 + export XR_RUNTIME_JSON=${monado}/share/openxr/1/openxr_monado.json 13 + # Tell Steam Pressure Vessel to allow access to Monado 14 + export PRESSURE_VESSEL_FILESYSTEMS_RW=$XDG_RUNTIME_DIR/monado_comp_ipc 15 + exec "$@" 16 + ''; 17 + } 18 +
+4
pkgs/top-level/all-packages.nix
··· 5968 5969 ondir = callPackage ../tools/misc/ondir { }; 5970 5971 osdlyrics = callPackage ../applications/audio/osdlyrics { }; 5972 5973 ossutil = callPackage ../tools/admin/ossutil { };
··· 5968 5969 ondir = callPackage ../tools/misc/ondir { }; 5970 5971 + opencomposite = callPackage ../development/libraries/opencomposite { }; 5972 + 5973 + opencomposite-helper = callPackage ../development/libraries/opencomposite/helper.nix { }; 5974 + 5975 osdlyrics = callPackage ../applications/audio/osdlyrics { }; 5976 5977 ossutil = callPackage ../tools/admin/ossutil { };