# Building Pointcaster

Source code for Pointcaster is available on [Github](https://github.com/matth-av/pointcaster). Start by cloning the repository:
```sh
git clone https://github.com/matth-av/pointcaster.git
cd pointcaster
```

## Linux

Builds on Linux use a containerised development environment created using the [Dockerfile](https://github.com/matth-av/pointcaster/blob/qt/Dockerfile) in the root of the repository. This handles download and configuration of all dependencies. Either [Docker](https://docs.docker.com/engine/install/) or [Podman](https://podman.io/docs/installation) must be installed and configured on your system to proceed.

The container image can be pulled from Pointcaster servers:
```sh
docker pull cr.pointcaster.net/pointcaster-dev
```

Or you can build it yourself (but it will take a while):
```sh
docker build -t pointcaster-dev .
```

It can be run directly to create release builds:
```sh
docker run --rm -v ./:/pointcaster:Z cr.pointcaster.net/pointcaster-dev \
    ./scripts/build-linux-release.sh
```
The `-v` argument ensures the repository is mounted inside the container.

For a development shell, invoke `bash` or `fish`, then you can configure and build using `cmake`:
```sh
docker run --rm -it -v ./:/pointcaster:Z cr.pointcaster.net/pointcaster-dev bash
```
Then from inside:
```sh
cmake --preset linux-release
cmake --build build/linux-release
cmake --build build/linux-release --target install
cmake --build build/linux-release --target package
```

The install target places a portable build at `build/linux-release/install/bin/pointcaster`, and the package target creates an AppImage at `dist/pointcaster-<version>-linux-release.AppImage`, both of which can be run from outside the container.
> [!TIP]
> The docker image is used as a base for a [Development Container](https://containers.dev/) in IDEs that support it. Visual Studio Code will automatically install extensions needed for C++, CMake and QML. See the [devcontainer.json](https://github.com/matth-av/pointcaster/blob/qt/.devcontainer/devcontainer.json).

## Windows
### Windows Builds Using Docker
Automated Windows builds use [Docker](https://docs.docker.com/engine/install/) to configure the build environment. [`scripts/windows.Dockerfile`](https://github.com/matth-av/pointcaster/blob/qt/scripts/windows.Dockerfile) installs Visual Studio Build Tools and other binary dependencies in a Windows container. This is how release builds are produced, but if you are looking to develop Pointcaster or a Pointcaster plugin you'll most likely want to build and debug using an IDE - in which case you might prefer [installing dependencies manually](#windows-builds-in-an-ide).

The following commands assume you have a working docker installation capable of running Windows containers on the command line.

The container image can be pulled from Pointcaster servers:
```sh
docker pull cr.pointcaster.net/pointcaster-dev
```

Or you can build it yourself (but it will take a while):
```sh
docker build -t pointcaster-dev .
```

To produce a Pointcaster release package:
```
docker run -v ./:C:\pointcaster cr.pointcaster.net/pointcaster-dev \
    .\scripts-build-windows-release.ps1
```
The `-v` argument ensures the repository is mounted inside the container.

For a development shell:
```
docker run -it -v ./:C:\pointcaster cr.pointcaster.net/pointcaster-dev powershell
```
And from inside the container:
```sh
cmake --preset windows-release
cmake --build build/windows-release
cmake --build build/windows-release --target install
cmake --build build/windows-release --target package
```
The install target places a portable build at `build/windows-release/install/pointcaster.exe`, and the package target creates a zip archive at `dist/pointcaster-<version>-windows-release.zip`.
> [!TIP]
> You might benefit from passing some docker args to fully utilise available resources, e.g.:
> ```sh
> docker run --memory=20G --cpus=16 ...
> ```

### Windows Builds in an IDE
#### Development Dependencies
To build Pointcaster on Windows using an IDE like Visual Studio, you'll need to install the following libraries on your host:
- Qt ~~QtVersion~~, with the 'shadertools', 'quick3d' and 'tasktree' modules
- oneAPI Threading Building Blocks (oneTBB) ~~TbbVersion~~
- Python ~~PythonVersion~~
- Jinja ~~Jinja2Version~~
- NVIDIA CUDA Toolkit ~~CudaVersion~~

Additionally, your environment will need CMake, vcpkg, Ninja, and MSVC from Visual Studio 2022.
These are all included in Visual Studio's 'Desktop Development with C++' Workload.
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9