Selecting a backend in CMake

The TGUI_BACKEND setting can be set to several values which are explained below. The SFML backend is selected by default.

SFML

When the SFML backend is selected, TGUI will use the sfml-graphics module for rendering.

If SFML is not automatically found by CMake then the SFML_DIR variable needs to be filled in. This property should contain the directory that contains the SFMLConfig.cmake file (just the path without the filename).
If you downloaded or installed SFML then the file can usually by found in the lib/cmake/SFML folder. If you build SFML yourself without installing it then SFML_DIR will be the build folder.
Note that the the file you need is called exactly “SFMLConfig.cmake”, the “SFMLConfig.cmake.in” file is not the correct one.

SDL

TGUI also has a backend based on SDL. It uses SDL2, SDL_TTF and OpenGL. At least OpenGL 3.2 or OpenGL ES 2.0 is required.

If SDL2 isn’t found automatically in CMake then fill in the SDL2_PATH variable with the root folder of the development libraries that you download from the SDL download page.
If SDL_ttf isn’t found automatically then fill in the SDL2_TTF_PATH variable with the root folder of the development libraries that can be downloaded from the SDL_ttf download page.

You can set the hidden TGUI_USE_GLES option to TRUE if you want to use OpenGL ES instead of OpenGL (you have to manually create the entry if you use the CMake gui). This property must be set to TRUE when building for Android and setting it to TRUE is also recommended when building for the Raspberry Pi.

Custom

While the other options are about building a single backend, it is also possible to build TGUI without any integrated backends (to use your own custom backend) or to build multiple backends so that you can choose one at runtime.

After you select the “Custom” backend in the CMake gui, you need to press the “Configure” button to see more options. The following options will become available:

TGUI_HAS_BACKEND_SFML: Sets whether the SFML backend should be build.

TGUI_HAS_BACKEND_SDL: Sets whether the SDL backend should be build.