Inviwo Setup for Mac

The steps below detail how to get Inviwo running on a computer with MacOS (tested on High Sierra). The video shows all of those steps as well. In parts, it is heavily sped up. Especially the last step - building Inviwo - does take some time. 

If you are working on a new Mac with the Apple Silicon chip, the instructions for getting one of the dependencies (Qt) is slightly different. If you took the introduction course, this means with this update it should now be possible to build Inviwo as well :)

(Note: The video was created for a prior version of Inviwo. Since then sub modules have been introduced and the newest XCode version uses a slightly different build system (see below for both).)

Play media comment.

Step 1: Installing Dependencies

In order to work with Inviwo, you will need to install Git, XCode, Qt and CMake. If there is some dependency you already have installed, check below if the versions are recent enough.

Git

Download git (Git Download Links to an external site.) and follow the install prompt.

XCode (>= 9.3)

Install XCode from here: XCode Download Links to an external site.. Make sure your installation contains the Command Line Tools which contain the C++ compiler. Restart after this step.

You can check if installation was successful by running 

xcode-select -p

which will return the location of the Command Line Tools (usually /Library/Developer/CommandLineTools).

If CMake is not successful in finding XCode or a C++ Compiler, open XCode and navigate to XCode -> Preferences.. -> Locations and select your XCode version under Command Line Tools:

CommandLineToolsXCode.png

You may have to restart your computer for this change to take effect that CMake can pick up on it. If XCode is still unable to find a C++ compiler, you can also set it manually, by adding the variables CMAKE_CXX_COMPILER and CMAKE_C_COMPILER 'filepath' vars to CMAKE using the gui ('Add Entry') and setting them to the result of 

xcrun -find c++ 

and

xcrun -find cc

e.g. CMAKE_CXX_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
CMAKE_C_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc

QT (>= 5.12)

If you use a Mac that still has an Intel chip, install Qt from here: Qt Download Links to an external site.. Choose the MacOs component and then add Qt folder to the CMAKE_PREFIX_PATH environment variable

export CMAKE_PREFIX_PATH=/Users/username/Qt5.12/5.12.4/clang_64/

If the installer claims the size of the install is several Gb large, you probably selected more than just the specified component above.

For the newer models with an Apple Silicon chip, you should be able to use homebrew Links to an external site. (> 2.7 Links to an external site.) to install qt5. This required installing homebrew and XCode beforehand and may affect the location where qt is installed. 

brew install qt@5

CMake (>= 3.12)

Use the installer for your Mac OS version from here: CMake Download Links to an external site.

Step 2: Cloning Inviwo

The source code is available on Github. You can clone the Inviwo repository by running

git clone https://github.com/KTHVisualization/inviwo

on the command line (or by using some graphical user interface for git). This will make a local copy of the source code on your computer in the current folder of the command line. Navigate to the newly created folder with

cd inviwo

Then, clone the repositories submodules with 

git submodule update --init --recursive

Step 3: Running CMake

Run the CMakeProgram. In the window that opens you need to specify two paths. The first is the path of the folder with the Inviwo source (this is the folder with the contents of the git repository, so something like /Users/Username/inviwo). The other path is the one where CMake will place the build-files (e.g. /Users/Username/inviwo-output). Specify these two paths and hit the Configure button. 

You will be asked if you want to create the output folder (Yes) and to choose which generator to use. You want to use the XCode generator. This is often already the default setting. Then CMake will do some checks for what system you are using and set up the build environment accordingly.

You will see some variables with either values or checkboxes. These specify which parts of Inviwo we will be using and where certain dependencies are located. If everything worked correctly, you will not have to make any changes here. Continue to press Configure until none of the entries are marked red anymore. However, one common problem is that CMake is unable to find Qt or uses a version that is incorporated into another program. Therefore check that the variables QT_QMAKE_EXECUTABLE (the location where you have installed Qt has a subfolder structure that should be something like /Users/username/Qt5.12/5.12.4/clang_64/bin- specify the qmake file) and the variables Qt5*_DIR (e.g. Qt5Core_DIR should be something like /Users/username/Qt5.12/5.12.4/clang_64/lib/cmake/Qt5Core, again you need the location where you installed Qt) are set to the correct folders.

If you installed Qt with homebrew, the Qt is located within the homebrew directory, e.g. QT_QMAKE_EXECUTABLE=/opt/homebrew/Cellar/qt@5/5.15.2/bin/qmake, Qt5Core_DIR=/opt/homebrew/Cellar/qt@5/5.15.2/lib/cmake/Qt5Core

If all settings are correct and no errors occurred, you can hit Generate.

Step 4: Building Inviwo

The button Open Project should now directly open the Visual Studio solution of Inviwo. You can also navigate to the output folder you have specified and open the file inviwo-projects.xcodeproj from there. You furthermore have to edit the build scheme (Product → Scheme → Edit Scheme...) while ALL_BUILD is selected and set the executable for Run as inviwo.app.

For faster execution you may want to choose Release in the Build Configuration. The Debug mode is needed when you want to step through your code.

Now all that is left to do is build Inviwo (Product → Build) .  If the build fails, you may have to enable the legacy build system (File > Project Settings > Build System: Legacy Build System).

If Inviwo does not start from XCode, you might need to navigate to the folder and open the Inviwo app from there. You will then be asked if it is okay to run programs in this folder. Inviwo should be able to start from XCode as well after confirming this.

Once Inviwo runs on your machine, you can take a look at the different example workspaces (File → Example Workspaces).