Simple Game Graphics Library  1.0
Building SGG

The first step is to download the library from the online GitHub repository. If you have git installed you can open your command line and execute the following command.

git clone https://github.com/cgaueb/sgg.git

or simply download the .ZIP file and extract it somewhere on your PC.

The library currently comes with build scripts for Windows and Linux. It is written in standard C++ and depends on well supported, cross-platform libraries. Building for different operating systems and compilers should be straightforward.

After cloning or unzipping, the directory structure should be as follows:

3rdparty/ Dependencies and assets
doc/ Documentation
demo/ Source for a sample application that depends on SGG
sgg/ Source for the SGG library itself. !No need to modify
build_demo_x64.bat Windows demo build script
build_demo_x64.sh Linux demo build script
build_demo_macOS.sh Mac OS demo build script
build_sgg_x64.bat Windows SGG build script
build_sgg_x64.sh Linux SGG build script
build_sgg_macOS.sh Mac OS SGG build script

Windows (Visual Studio 2019 - MSVC)

1) First, make sure you have Visual Studio 2019 installed on your system.

2) To build the library simply double click on the build_sgg_x64.bat. This script builds both a Release (sgg.lib) and a Debug (sggd.lib) version of the library. The resulting libraries are stored in the lib folder.

These are the libraries we need to link to our program in order to use the functions of SGG. The additional dependencies required for the library are conveniently included in the 3rdParty folder.

3) To test the library, you can double click on the build_demo_x64.bat to build the demo application found in demo and uses the SGG library. After a successful build, the executable can be found in bin.

Linux (GCC)

1) First, we need to make sure that we have the GCC compiler setup properly. The best option is to use our distribution's package manager. The following steps use the apt command line tool that is commonly found in Ubuntu/Debian Linux distributions.

We need to execute the following commands as root or a user with sudo privileges.

sudo apt-get update

sudo apt-get install build-essential

The first command updates the system's package information.

The second command installs the essential tools for building from C++ source code. (gcc, libc e.t.c.)

2) Next, we will need to install development versions of the 3rd party libraries that SGG depends on.

This is again very easy using our system's package manager.

sudo apt-get install libsdl2-dev libsdl2-mixer-dev libglew-dev libfreetype6-dev

3) After properly installing gcc and the 3rd party dependencies, the library can be built using the provided script. In your terminal, change directory to within the downloaded folder and execute the command:

./build_sgg_x64.sh

This script builds both a Release (libsgg.a) and a Debug (libsggd.a) version of the library. The resulting libraries are stored in the lib folder.

These are the libraries we need to link to our program in order to use the functions of SGG.

4) To test the library, you can execute ./build_demo_x64.sh to build the demo application found in demo and uses the SGG library. After a successful build, the executable can be found in bin.

CMake (with Vcpkg)

1) Follow the instructions at https://github.com/microsoft/vcpkg to install the vcpkg package manager at your desired location.

2) Use Vcpkg to install the required dependencies with the following commands.

vcpkg install glew:x64-windows-static
vcpkg install sdl2:x64-windows-static
vcpkg install sdl2-mixer:x64-windows-static
vcpkg install freetype:x64-windows-static
vcpkg install glm:x64-windows-static

3) To continue, we have two options. In the following commands, replace the /path/to/vcpkg/directory placeholder with the proper path to your Vcpkg installation directory.

[Option 1 (Recommended)] Configuring project with vcpkg toolchain and registry support

This will automatically register the library's build tree to cmake. It will also auto find it's dependencies through vcpkg's toolchain without requiring the dependent project to use the vcpkg toolchain itself. This is the most convenient option when building for personal usage.

cmake -B build -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_PACKAGE_REGISTRY=ON \
-DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/directory/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=x64-windows-static

[Option 2] Configuring project with vcpkg toolchain and no registry support

This will force dependent projects to have a global or local installation of the package available. The installed folder is supposed to be packaged and distributed to different computers so it can't reuse the vcpkg config files as they may not be available. The dependent projects will have to either supply the vcpkg toolchain themselves or use any other way so as to make the library's dependencies discoverable. For example one may also use the conan package manager, cmake-supplied Find modules, system installed config files or local Find modules.

cmake -B build -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/directory/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=x64-windows-static

4) To build, we execute the command

cmake --build build

At this point, if configured using Option 1, the library will be available for consumption from other cmake projects.

5) For global installation use:

cmake --build build --target install

For installation to a destination folder, re-configure with CMake to set the CMAKE_INSTALL_PREFIX:

cmake -B build -DCMAKE_INSTALL_PREFIX=dest
cmake --build build --target install

Usage

Dependent projects can use find_package(sgg REQUIRED) in their CMakeLists.txt and then link to the sgg::sgg target.