.. _installation-compilation-macos:
---------------------
Building guide: MacOS
---------------------
IDSimF is developed and tested on MacOS extensively. This guide is describing compilation on MacOS Monterey with the open source package management system `Macports `_. However, compilation of IDSimF on other MacOS versions and with different package management systems, particularly `Homebrew `_, should be possible in a similar way to this guide.
This installation guide assumes that you have `Macports `_ installed. Xcode and the Xcode commandline tools are required for Macports and are therefore assumed to be installed too. This guide also assumes that you have basic familiarity with the command line / terminal and the ``port`` command line tool of Macports.
Update package sources, install ``git`` and ``cmake``:
------------------------------------------------------
First the macports installation and the package sources should be updated:
.. code-block:: console
sudo port selfupdate
Install ``git`` with macports:
.. code-block:: console
sudo port install git
Install ``cmake`` with macports:
.. code-block:: console
sudo port install cmake
This should make ``git`` and ``cmake`` available. This can be verified by checking their versions:
.. code-block:: console
$ git --version
git version 2.28.0
$ cmake --version
cmake version 3.23.3
Install a C++17 compatible C++ compiler :
-----------------------------------------
IDSimF is written in C++17, therefore a recent compiler fully supporting the C++17 language standard has to be used to compile IDSimF. The c++ compiler of `gnu compiler collection (gcc) `_ gnu compiler collection (``g++``
) in major version 12 is readily available with macports and is compatible with IDSimF. Install it with
.. code-block:: console
sudo port install gcc12
Alternatively, the `llvm `_ c++ frontend `clang `_ in major version 14 is also available and can be used to compile IDSimF. Install it with
.. code-block:: console
sudo port install clang-14
Clone the IDSimF repository
---------------------------
.. include:: default_git_clone.rst
Configuration and building with ``cmake``
---------------------------------------------
Preparing the build
...................
IDSimF uses ``cmake`` as helping tool for configuration and compilation. ``cmake`` allows a so called "out of source build". This creates a separated "binary tree" in a separated build folder, in which the compilation of executable binaries takes place without interfering with the cloned sources.
To do an out of source build, change into the cloned IDSimF folder and create a build folder, for example ``build`` in it and change into it:
.. code-block:: console
cd IDSimF
mkdir build
cd build
Basically ``cmake`` prepares a build tree in the current folder if it is called with an source folder as argument. However, since we do not want to build with the default compiler of the system, we have to set some options for ``cmake``. This is done with optional arguments of the form ``-D