\page installation Installation

The library ships with a CMake-based installation file, that can be used to compile and install the library either as a static or shared (dynamic) library across different platforms. It uses Conan as the package manager to get all required dependencies into the project (here, Doxygen for creating the documentation, and Gtest for running the tests, both dependencies are optional).

All source code is provided within the `meshReaderLib` folder. In order to test that the library is working correctly, the compilation can be tested with a few tests that are provided in the `tests` folder. We use CTest to execute all tests after successful compilation.

### Check system requirements

First, we will need to ensure that the minimum requirements are satisfied. We need CMake (minimum version 3.23), Python (version 3.X), and a C++ compiler.

We can check that we have these installed by typing

```bash
# check cmake
cmake --version

# check python (Linux, macOS)
python3 --version

# check python (windows)
py --version

# check compiler (Linux)
g++ --version

# check compiler (macOS)
clang++ --version

# check compiler (windows)
cl.exe
```

If all of these return a version and no error message we are ready to go.

### Installing dependencies

We use the Conan package manager to install all of our dependencies. If you have not installed it yet, you can check out [this guide](https://cfd.university/learn/automating-cfd-solver-and-library-compilation-using-cmake/how-to-add-external-libraries-into-your-cfd-solver-using-cmake#aioseo-the-preferred-way-using-a-package-manager) to get it installed and set up. Once you have Conan installed and a sensible profile available, you can install all required packages using the following command:

```bash
conan install . -pr dev --output-folder=build --build=missing
```

Where I am using my ```dev``` profile, though you can omit this if you just want to install everything using your default profile. To make Doxygen available, we have to source the environmental variables for Conan, which are located in the ```build/``` folder. To do so, change into the ```build/``` and then execute the following

```bash
# UNIX
./conanbuild.sh

# Windows
.\conanbuild.ps1
```

Conan does not generate PowerShell (```*.ps1```) files by default, but the above-linked article will show how this can be requested within the profile settings.

### Compiling the project

Next, we can compile the project from within the ```build/``` folder. The following command builds the library as a shared (dynamic) library, along with documentation and tests:

```bash
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -DBUILD_DOCS=ON -DENABLE_SHARED=ON -DENABLE_TESTS=ON -G Ninja ..
```

The build-type is set to Debug, and we are using the ```conan_toolchain.cmake``` file that was generated by Conan. I am also using the ```Ninja``` build tool, but if you want to use your native build tool, you can omit the ```-G Ninja``` CMake flag.

With the project configured, we are now in a position to compile the project using

```bash
cmake --build . --config Debug
```

Finally, if we want to install it to a specific directory on our system, we can add an install step

```bash
cmake --install . --prefix C:\temp --config Debug
```

where the ```--prefix``` determines the location where the library and documentation should be installed to.

We can also create the graphical installer if we want, which requires the Qt installer framework (IFW). You can find [installation instructions here](https://cfd.university/learn/automating-cfd-solver-and-library-compilation-using-cmake/how-to-use-cmake-cpack-to-create-beautiful-gui-installers#aioseo-getting-the-qt-install-framework). If this is installed, then creating the installer is as simple as typing

```bash
cpack
```

If we request to build the tests along with the project, then we can use CTest to check that all tests are passing as expected:

```bash
ctest
```