Skip to content

Building

andry edited this page Apr 20, 2019 · 1 revision

There are various ways to build the project, either standalone (via CMake) or with Conan (Conan package or Meson build). If building with CMake, tewi will prefer the standalone version if CMake can find the correct repos inside external/, else it will fallback to FindPackage (so either Conan or your system dependencies)

Index

Required build env

Any C++17 compiler.

Conan package

The Conan package requires CMake to build correctly, Meson support is experimental!

To build tewi you first need to build asl, so clone the repo and create the Conan package:

git clone https://github.com/andry-dev/asl
cd asl
conan create . andry/dev

Then just clone tewi and also create the Conan package:

git clone https://github.com/andry-dev/tewi
cd tewi
git submodule update --init external/imgui # (for packaging with ImGui)
conan create . andry/dev

And you're done. If you want to use the library now you just need to include tewi in your conanfile.txt:

[requires]
tewi/0.1@andry/dev

Options

Table with possible packaging options:

Option Values Description Default
integrate_imgui true or false Integrates ImGui inside tewi True
enable_vulkan true or false Enables Vulkan support (experimental) False

To integrate ImGui you need to initialize the relevant submodule inside external/imgui, else the build will fail:

cd [tewi's git repo]
git submodule update --init external/imgui

Standalone CMake

It is possible to build without using Conan, with the help of git submodules.

Required runtime

You need a compiled version of GLEW somewhere in your system. You may need to figure this one out on Windows.

Instructions

Either clone the full repo with --recursive or initialize the submodules one by one:

git clone https://github.com/andry-dev/tewi --recursive
# OR
# git clone https://github.com/andry-dev/tewi
# cd tewi
# git submodule update --init external/imgui

Then just build as you normally would with CMake:

mkdir build
cd build
cmake ..
cmake --build .

Options

Option Values Description Default Remarks
TEWI_BUILD_TESTS 0 or 1 Whether to build tests 0
TEWI_BUILD_EXAMPLES 0 or 1 Whether to build examples in examples/ 0
TEWI_ENABLE_VULKAN 0 or 1 Include Vulkan support 0 You need Vulkan libraries in your system
TEWI_USE_TOOLS 0 or 1 Enable support for using various tools in the codebase 0
TEWI_INTEGRATE_IMGUI 0 or 1 Enable ImGui support, this provides an OpenGL backend for ImGui integrated in tewi 1 You need to init the ImGui git submodule in external/imgui
BUILD_SHARED_LIBS 0 or 1 Build tewi as a dynamic library 0 You may need the dynamic library of GLEW in your system

Regarding submodules

CMake will try to find the directories in external/ first before attempting to call FindPackage(). This is useful in case you want to provide your patched version of any library or use a particular git release. Or it's useful in case you just want to avoid Conan in general.

external
├── imgui
├── glfw
├── stb
├── glm
└── asl

Just to be clear, you can init just one of those dirs if you just want to build one submodule. If, for example, I want to build the latest GLFW and asl but still use FindPackage to find the other dependencies I can just do:

git submodule update --init external/glfw
git submodule update --init external/asl

And it will work just fine, it will build the two libraries (plus ImGui if specified) but still use FindPackage() to resolve the others.

In the future glm will be an optional dependency like ImGui, enabled either in Conan or by initializing the submodule.

Meson

There is experimental support for Meson, it is therefore encouraged to just use CMake.

You can also build the library with Meson + Conan. First of all you need to build asl as a Conan package:

git clone https://github.com/andry-dev/asl
cd asl
conan create . andry/dev

Then clone tewi and build with Meson, specifying where to find pkg-config files:

git clone https://github.com/andry-dev/tewi
cd tewi
git submodule update --init external/imgui

mkdir build
cd build
conan install ..

cd ..
env PKG_CONFIG_PATH="build/" meson build

At this point you should get the library built.

Caveats with Meson

You still need Conan for the dependencies (or at the very least for asl), there are no build options and dynamic linking is currently unsupported.

Clone this wiki locally