Note that the cmiclab repository is the main repository while the sourceforge only contains the master branch.
Compile and install the source on Windows
Create a folder to build the code and another one to install the code, e.g. niftyreg_build and niftyreg_install respectively.
Launch CMake-Gui. Set the source path to niftyreg (where you copied/cloned the source files) and the build path to niftyreg-build then hit configure. CMake-Gui will prompt you to select the generator, which means you'll need to select a version of Visual Studio that have been installed on your computer. CMake-Gui will present you with some configuration options. Once you have selected your desired options and set the CMAKE_INSTALL_PREFIX option to the folder where you want to install NiftyReg (e.g. niftyreg_install), press configure and then generate. CMake-gui will generate the Visual Studio project files. Below is an example of selected options:
Go to the niftyreg_build folder. You can see below the files that are generated by CMake-gui in the niftyreg_build folder:
Double click on the file NiftyReg.sln and Visual Studio will start up. In Visual Studio select build type, for generic use select Release and build the project (hit F7). Once the build is finished select and run the install task (Right Click on Install > Project Only > Build only Install). This will install NiftyReg to the folder you selected earlier.
You could then install the niftyreg_install folder to your system path.
Compile and install the source on Linux or MacOs
Create the folders niftyreg_build and niftyreg_install:
In the terminal, change directory to the niftyreg_build folder and run the following command:
Press the c key to configure the project. Set CMAKE_INSTALL_PREFIX to niftyreg_install. Below is an example after the option configuration on MacOs:
Once all the options have been configured, press c to configure and then g to generate.
In the terminal run the following commands:
The code will be installed in niftyreg_install and you can update your ~/.profile or ~/.basrc file with the following lines:
After opening a new terminal, you should be able to run:
CMake configuration Niftyreg specific options
If set to ON, the z library will be build even if it is available on the computer.
If set to ON, some part of the code under development will be build.
If set to ON, the NiftyReg libraries will be build as shared. They are built as static by default.
If set to ON, the data for testing as well as the unit tests will be build. It requires matlab to generate the test data.
If set to ON, the code is compiled using CUDA.
If set to ON, the code is compiled using OpenCL
If set to ON, the code is compiled using OpenMP. Not that this can not be done with a clang compiler.
If set to ON, the code is compiled using SSE. SSE code is mostly present in the cubic spline deformation field computation.
Building the unit tests
When the BUILD_TESTING flag is CMake is set to ON, the relevant data and executables are generated. The data are generated using Matlab, hence the need to have matlab installed, from one 2D and one 3D image provided by the user. These images are provided through the variables TESTING_2D_FILE and TESTING_3D_FILE to CMake. The Matlab root path can be specified using the Matlab_ROOT_DIR variable if it is not automatically detected.
Compiling with OpenMP and CUDA on MacOs
CUDA on MacOs is not compatible with gcc and requires clang as a compiler while OpenMP is not supported by clang but is supported by gcc. In order to compile NiftyReg with both OpenMP and CUDA, one need to compile the C/C++ code with gcc and the CUDA code with clang. This can be achieved by setting the following variables accordingly:
CMAKE_C_COMPILER and CMAKE_CXX_COMPILER to gcc and g++ respectively and CUDA_HOST_COMPILER to clang.
The following command line can be use to set up all relevant variables directly: