KitwareMedical / SlicerVirtualReality

A Slicer extension that enables user to interact with a Slicer scene using virtual reality.
Apache License 2.0
119 stars 58 forks source link

Disable OpenXR runtime on macOS and remove stub module #150

Closed jcfr closed 10 months ago

jcfr commented 10 months ago

Since attempting to build on macOS results into few errors described below, this commit sets the default value for SlicerVirtualReality_HAS_OPENXR_SUPPORT to OFF.

It also removes the VirtualRealityStub module and re-enable support for building on macOS. This means an extension will be built but it would not have any working XR runtimes.

macOS errors related to OpenXR-SDK and vtkRenderingOpenXR

Issue finding "OpenGL.framework"

During the configuration of the external project associated with the vtkRenderingVR project, error like the following was reported:

  CMake Error in /D/S/A/VTK/Rendering/VR/CMakeLists.txt:
    Imported target "VTK::RenderingOpenGL2" includes non-existent path
      "/Applications/Xcode-14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/Library/Frameworks/OpenGL.framework"
    in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
    * The path was deleted, renamed, or moved to another location.
    * An install or uninstall procedure did not complete successfully.
    * The installation package was faulty and references files it does not
    provide.

It was fixed by adding the missing symlink:

cd /Applications/Xcode-14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
ln -s MacOSX.sdk MacOSX14.0.sdk

Issue building "OpenXR-SDK" project

The following was reported when linking the libopenxr_loader library:

  [  6%] Linking CXX shared library libopenxr_loader.dylib
  -macosx_version_min has been renamed to -macos_version_min
  ld: unknown options: --version-script=/D/S/S-0-E-b/SlicerVirtualReality-build/OpenXR-SDK/src/loader/openxr-loader.map --no-undefined
  clang-14: error: linker command failed with exit code 1 (use -v to see invocation)

Updating "OpenXR-SDK" from release-1.0.26 to release-1.0.32 allows to address this.

Issue resolving "XrGraphicsBindingOpenGL"

Here is the error reported while building the vtkRenderingOpenXR module:

    [ 15%] Building CXX object vtkRenderingOpenXR/CMakeFiles/RenderingOpenXR.dir/vtkOpenXRManagerConnection.cxx.o
  In file included from /D/S/A/VTK/Rendering/OpenXR/vtkOpenXRManagerOpenGLGraphics.cxx:15:
  /D/S/A/VTK/Rendering/OpenXR/vtkOpenXRManagerOpenGLGraphics.h:119:19: error: use of undeclared identifier 'XrGraphicsBindingOpenGL'
    std::shared_ptr<XrGraphicsBindingOpenGL> GraphicsBinding;
                    ^
  /D/S/A/VTK/Rendering/OpenXR/vtkOpenXRManagerOpenGLGraphics.h:49:16: error: cannot initialize return object of type 'vtkObjectBase *' with an rvalue of type 'vtkOpenXRManagerOpenGLGraphics *'
    vtkTypeMacro(vtkOpenXRManagerOpenGLGraphics, vtkOpenXRManagerGraphics);
    ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jcfr commented 10 months ago

With this change, here the configuration output. Since it was done from an existing build tree, the variable habe been explicitly removed to simulate a clean build.

cmake \
  -USlicerVirtualReality_HAS_OPENVR_SUPPORT \
  -USlicerVirtualReality_HAS_OPENXR_SUPPORT .

[...]
-- 
-- Setting SlicerVirtualReality_HAS_OPENVR_SUPPORT to OFF (OpenVR not supported on macOS)
-- 
-- 
-- Setting SlicerVirtualReality_HAS_OPENXR_SUPPORT to OFF (OpenXR not supported on macOS)
-- 
-- SlicerVirtualReality_EXTERNAL_PROJECT_DEPENDENCIES:vtkRenderingVR
-- Remote - VTKExternalModule [OK]
-- Remote - VTKExternalModule_SOURCE_DIR:/D/S/S-0-E-b/SlicerVirtualReality-build/VTKExternalModule
-- SuperBuild - First pass
-- SuperBuild - First pass - done
-- SuperBuild - inner => Requires vtkRenderingVR, 
-- SuperBuild -   vtkRenderingVR[OK]
-- SuperBuild -   VTK_SOURCE_DIR:/Users/svc-dashboard/D/S/A/VTK-build/../VTK
-- SuperBuild -   vtkRenderingVR_DIR:/D/S/S-0-E-b/SlicerVirtualReality-build/vtkRenderingVR-build
-- SuperBuild - inner[OK]
-- Configuring done
-- Generating done
-- Build files have been written to: /D/S/S-0-E-b/SlicerVirtualReality-build

We can observe the two XR runtime OpenVR and OpenXR are disabled. Only the generic base vtkRenderingVR module is being built.

...
[100%] Built target qSlicerVirtualRealityModuleGenericCxxTests
[ 94%] Forcing configure step for 'inner'
[ 94%] No install step for 'inner'
[100%] Completed 'inner'
[100%] Built target inner