Build instructions MacOS - neutronimaging/imagingsuite GitHub Wiki

Prerequisites

Tools to install

To build the libraries and applications of the ImagingSuite, you will need:

  • A C++ compiler that can compile C++17 code. The main component needed to build the imagingsuite is the compiler Xcode (command line tools). It can be downloaded on Xcode or on AppStore.
  • Qt 6.2.x and newer. Download Qt there is a free community version. The Qt installation includes the IDE Qt Creator.

Installing dependencies

Packet manager

The imaging suite also needs a collection of gnu dependencies. These are best installed using Homebrew.

brew install cmake
brew install armadillo
brew install FFTW
brew install pybind11
brew install cfitsio

Install NeXus

NeXus is a library to read and write files in the HDF5-based format. It can be tricky to get running on MacOS. The best way seems to be to compile locally and install on the default path.

mkdir build
cd build
cmake ../code-4.4.2 -DENABLE_HDF5=1 -DENABLE_CXX=1  -DCMAKE_BUILD_TYPE=Release  
cmake --build . --target install

Install tries to copy the files to /usr/local in the subfolders lib, share, and include. So, you may need to used sudo for the installation.

Environment variables

Set the environment variables on MacOS. This best done in the file ~/.zshrc:

  • WORKSPACE to the location of your git root folder e.g. ~/git
  • QTBINPATH to the bin folder of your Qt installation

These variables will be used by build and deployment scripts to find build tools for the used Qt distribution. By using these variables there is no need to locally modify the build scripts.

Building

Create folder structure

Navigate to the repos root <WORKSPACE> and create the folders needed for build and deployment.

cd <WORKSPACE>
mkdir build-imagingsuite install deployed
cd build-imagingsuite

Start the build

The imaging suite is built using cmake for the build configuration. This is a tool that can be installed separately, but here we will use the cmake provided by Qt. This has the advantage that Qt dependencies are found automatically during the build. The first step is to configure the build by referencing the CMakeLists.txt file in the root of the imagingsuite folder:

cmake ../imagingsuite -GNinja -DCMAKE_INSTALL_PREFIX=../install -DDYNAMIC_LIB=ON -DCMAKE_PREFIX_PATH=$QTPATH

Assuming you have defined the QTPATH varible. The Qt version must be updated to your version. Here, we used ninja as build tool. This is a much faster build tool than the default make.

Once the configuration finishes successfully we are ready to start the build

cmake --build . --target install

The resulting build artefacts are now copied to the folder <WORKSPACE>/install

Run unit tests

There is a collection of unit tests for the imagingsuite modules. These can be run using ctest. Go to the root of the build folder (<WORKSPACE>/build-imagingsuite is you used the same folders as in the instructions) and type

ctest

The tests depend on data from the TestData repository.

Deployment

The cmake-build creates the binaries for the application and their supporting libraries, but they can't be used as built. First you have to run a deployment script that copies additional dependencies and creates the correct paths for each lib and application. The muhrec deployment script is located in

<repos workspace>/imagingsuite/mac/deploy_muhrec_mac_arm64.sh
<repos workspace>/imagingsuite/mac/deploy_imageviewer_mac_arm64.sh

These scripts sense the CPU-type on the current system and copies the needed files.

The deployed app bundles obtain a dummy-signature using code sign. This makes it possible to run the application on any mac.

The deployment script copies the complete app bundle to the folder <repos workspace>/deployed as app bundles and also as .dmg file for distribution.

⚠️ **GitHub.com Fallback** ⚠️