Skip to content

Build Guide

Devon edited this page Apr 12, 2023 · 8 revisions

Foreword

In order to compile astera please make sure that you have a newer version of CMake (3.16+) installed.

If you have CMake installed but don't know the version, you can check with the command:

cmake --version

Setup

In this step we're looking to initialize the CMake build environment. In order to do so, make sure you're in the root directory of astera in your terminal of choice!

This is the bare-bones command you can run to get started. It will create the build directory in a new folder called build. The -S. part just specifies to CMake that the source's root directory is the root directory of the repository.

cmake -Bbuild -S.

For specific setup options, see CMake Options.

Now that we have the CMake environment initialized, we just have to call the build function. For ease, you can call it from the root directory via:

cmake --build build

Everything compiled will be located within the astera/build directory now.

Linux Dependencies

If you run into any issues, please check that you have all the required packages installed and are running the commands from the correct directory within your terminal! To find a solution you can always check the issues page.

Before compiling, you'll want to insure that you have the following libraries available on your system:

-GL (OpenGL, often via mesa)
-GLU (OpenGL Utilities)
-Xi
-Xrandr
-Xxf86vm
-Xinerama
-XCursor

Here are a few package lists for various Linux Distributions in case you need them installed:

Ubuntu:

sudo apt install mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev libopenal-dev

Alpine Linux:

sudo apk add mesa-dev libxrandr-dev libx11-dev libxi-dev freeglu-dev libxinerama-dev libxcursor-dev

Void Linux:

sudo xbps-install MesaLib-devel libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel libopenal-devel

Arch Linux

sudo pacman -S mesa libx11 libxi libxinerama libxcursor openal-git

NOTE: If you have a package manager on here that you'd like to see added, please create an issue and add the package names if you know them!

OpenAL (Windows)

Windows doesn't come with OpenAL by default, oftentimes it'll be installed with other games that use it. But in the case that you don't have OpenAL installed, you can download and install it from OpenAL's website here

NOTE: Download the Windows Installer

OpenAL (Mac & Linux)

For whatever reason, Apple appears to really not like OpenAL in particular. If you're on a Linux Distro which package manager doesn't have an OpenAL(-dev) package, you can follow these steps as well. You can compile and install OpenAL Soft which can work as a drop-in replacement for the otherwise deprecated OpenAL.

(MAC:) To install OpenAL-Soft you'll have to either download and compile it yourself or install it Homebrew.

(MAC/Linux/Windows:) To download and compile you can try something similar to:

git clone https://github.com/kcat/openal-soft
cd openal-soft
cmake ..

To install via homebrew, make sure you have homebrew installed and then run:

brew install openal-soft

Astera Options

In Astera's build system there are a few togglable options you can use:

  • ASTERA_DEBUG_OUTPUT - Enable internal astera debug output (debug.h)
  • ASTERA_BUILD_EXAMPLES - Enable building examples (disabled for projects including astera)
  • ASTERA_DEBUG_ENGINE - Enable internal debugging tools for debugging the engine itself (ASAN / Pedantic warnings)

CMake Options

If you want to specify a CMake Generator, you can add -G and then your option, I'm partial to ninja, so I'd add -GNinja. You can read more about CMake Generators here.

If you want to try and compile a specific candidate type (Release vs Debug), you can specify -DCMAKE_BUILD_TYPE with either Release or Debug. Which would look something like this:

-DCMAKE_BUILD_TYPE=Release 

If you'd like to specify a specific compiler use -DCMAKE_C_COMPILER= and -DCMAKE_CXX_COMPILER= in the command.

Here's an example of using all the options we just described:
Note: Keep in mind that the order of the options / arguments doesn't matter.

cmake -Bbuild -S. -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug
Clone this wiki locally