Skip to content

Commit 70d5a3b

Browse files
lassoanjcfr
andauthored
Fix extension build on macOS by replacing real Virtual Reality module by a placeholder
Virtual Reality is not supported on macOS. Instead of having a build error on the dashboard and extension missing from the Extensions Manager, we now create an extension that contains a stub module that just displays the message that Virtual Reality is not supported on the platform. fixes #92 Co-authored-by: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
1 parent 1f118fa commit 70d5a3b

5 files changed

Lines changed: 72 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ set(EXTENSION_DESCRIPTION "Allows user to interact with a Slicer scene using vir
1111
set(EXTENSION_ICONURL "https://raw.githubusercontent.com/KitwareMedical/SlicerVirtualReality/master/SlicerVirtualReality.png")
1212
set(EXTENSION_SCREENSHOTURLS "https://www.slicer.org/w/images/4/49/SlicerVirtualReality_Screenshot1.png https://www.slicer.org/w/images/0/04/SlicerVirtualReality_Screenshot2.png")
1313
set(EXTENSION_DEPENDS "NA") # Specified as a space separated string, a list or 'NA' if any
14+
15+
#-----------------------------------------------------------------------------
16+
if(APPLE)
17+
# Virtual Reality is not supported on macOS, create an extension that contains a stub module
18+
# that just displays the message that Virtual Reality is not supported. This avoids having
19+
# a build error on the extension build dashboard.
20+
find_package(Slicer REQUIRED)
21+
include(${Slicer_USE_FILE})
22+
add_subdirectory(VirtualRealityStub)
23+
include(${Slicer_EXTENSION_GENERATE_CONFIG})
24+
include(${Slicer_EXTENSION_CPACK})
25+
return()
26+
endif()
27+
#-----------------------------------------------------------------------------
28+
1429
set(EXTENSION_BUILD_SUBDIRECTORY inner-build)
1530

1631
set(SUPERBUILD_TOPLEVEL_PROJECT inner)

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ Usage
2727

2828
## Setup
2929

30-
Currently only Windows computers are supported, as until very recently there have been no virtual reality headsets officially supported on MacOS or Linux. If you already have virtual reality capable hardware, Steam
30+
**Platform support:** Currently the extension only works on Windows computers. Linux support is experimental: [Steam VR has limited support on linux](https://github.com/ValveSoftware/SteamVR-for-Linux/blob/master/README.md) and the Slicer extension is built for Linux but not tested. The extension is not available on macOS, as currently there are no virtual reality headsets available for macOS. If you wish to use Virtual Reality extension on Linux or macOS and you have virtual reality capable hardware and Steam VR works well on your computer then add a comment in the issue tracker ([macOS](https://github.com/KitwareMedical/SlicerVirtualReality/issues/3) / [Linux](https://github.com/KitwareMedical/SlicerVirtualReality/issues/57)).
3131

32-
works well on your computer, and you would like to use Slicer in virtual reality, too, then you add a comment in the issue tracker ([MacOS](https://github.com/KitwareMedical/SlicerVirtualReality/issues/3) / [Linux](https://github.com/KitwareMedical/SlicerVirtualReality/issues/57)).
33-
34-
If both integrated display card and high-performance GPU available in a system (typically this is the case on laptops with NVidia GPUs), then configure the graphics card application settings to use high-performance GPU for SlicerApp-real.exe (it is not necessary to use high-performance GPU for the launcher, Slicer.exe).
32+
**Configuring graphics:** If both integrated display card and high-performance GPU are available in a system (typically this is the case on laptops with NVidia GPUs), then configure the graphics card application settings to use high-performance GPU for `SlicerApp-real.exe` (it is not necessary to use high-performance GPU for the launcher, `Slicer.exe`).
3533

3634
<a name="setup-htc-vive" ></a>
3735

VirtualRealityStub/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#-----------------------------------------------------------------------------
2+
set(MODULE_NAME VirtualRealityStub)
3+
4+
#-----------------------------------------------------------------------------
5+
set(MODULE_PYTHON_SCRIPTS
6+
${MODULE_NAME}.py
7+
)
8+
9+
set(MODULE_PYTHON_RESOURCES
10+
Resources/Icons/${MODULE_NAME}.png
11+
)
12+
13+
#-----------------------------------------------------------------------------
14+
slicerMacroBuildScriptedModule(
15+
NAME ${MODULE_NAME}
16+
SCRIPTS ${MODULE_PYTHON_SCRIPTS}
17+
RESOURCES ${MODULE_PYTHON_RESOURCES}
18+
)
3.2 KB
Loading
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import slicer
2+
from slicer.ScriptedLoadableModule import *
3+
4+
#
5+
# VirtualRealityStub
6+
#
7+
8+
class VirtualRealityStub(ScriptedLoadableModule):
9+
def __init__(self, parent):
10+
ScriptedLoadableModule.__init__(self, parent)
11+
self.parent.title = "Virtual Reality"
12+
self.parent.categories = ["Virtual Reality"]
13+
self.parent.dependencies = []
14+
self.parent.contributors = ["Andras Lasso (PerkLab)"]
15+
self.parent.helpText = """
16+
This is a placeholder module to tell the user that Virtual Reality extension is not available on the platform.
17+
See more information in the <a href="https://github.com/KitwareMedical/SlicerVirtualReality">extension documentation</a>.
18+
"""
19+
self.parent.acknowledgementText = ""
20+
21+
#
22+
# VirtualRealityStubWidget
23+
#
24+
25+
class VirtualRealityStubWidget(ScriptedLoadableModuleWidget):
26+
def __init__(self, parent=None):
27+
ScriptedLoadableModuleWidget.__init__(self, parent)
28+
29+
def setup(self):
30+
ScriptedLoadableModuleWidget.setup(self)
31+
32+
def enter(self):
33+
"""
34+
Called each time the user opens this module.
35+
"""
36+
slicer.util.messageBox("Virtual Reality is not supported on this platform.<br>"
37+
"See <a href='https://github.com/KitwareMedical/SlicerVirtualReality#setup'>Slicer Virtual Reality extension website</a> for details.")

0 commit comments

Comments
 (0)