First, you have to make sure all requirements for building CardioMechanics are met. Afterwards, CardioMechanics can be build using CMake. Building from source was tested on Linux and Intel based Mac systems. ARM based Macs may require some changes.
The following requirements have to be installed before trying to build CardioMechanics from source. We recommend using a package manager (we use macports on our macOSX systems) whenever possible.
- C and C++ compilers (e.g. gcc/g++ or clang/clang++)
- CMake
- zlib
- gfortran
- git
- make
- PETSc
- VTK
- Open MPI
- Python3 (optional, if you want to use some of the provided tools)
With installRequirements.sh we provide a script to compile Open MPI, PETSc, and VTK from source with the most recently tested versions to ensure compatibility.
Building with CMake as described in the next step requires the location and version of the tools as set in the script.
If you do want to use alternative locations/versions you have to link them as required.
By default, the script installRequirements.sh compiles all components using a single process, which takes a considerable amount of time.
If you want to speed up this process, use the command make
with the option -j X
where X
is the number of processes you want to use.
Additionally, adjust export AUTOMAKE_JOBS=X
specifically for Open MPI.
Before continuing with compiling CardioMechanics using CMake, add the following environmental variables to your systems configuration file ( e.g. .bashrc or .zshrc)
export kaRootDir=$HOME/CardioMechanics
export THIRDPARTY_HOME=$kaRootDir/thirdparty
export PETSC_DIR=$THIRDPARTY_HOME/macosx
export PETSC_ARCH=petsc-v3.19.1
and add the location of the executables to your PATH variable (replace macosx with linux if you are on a linux machine).
PATH="$PATH:$THIRDPARTY_HOME/macosx/openMPI-64bit/bin"
PATH="$PATH:$kaRootDir/_build/bin/macosx"
PATH="$PATH:$kaRootDir/tools/python"
export PATH
We assume here that you copied the repository to your $HOME
directory.
If you chose a different root directory, adjust the kaRootDir
variable accordingly.
If you used a different PETSc version in installRequirements.sh, adjust the PETSC_ARCH
variable.
Now run
cmake -S . -B _build
to create the _build
folder and compile the code using
cmake --build _build