Visual Studio


Set the location of the TGUI directory, set the build directory (usually a new empty folder) and press “Configure”.
CMake Build Directory

Next select your generator, which is your Visual Studio version in this guide. Just keep the “Use default native compilers” option checked and ignore the other three options.
CMake Select Generator

If SFML cannot be found automatically you will receive an error.
CMake SFML not found

If SFML was not found then you should set SFML_DIR to the folder containing SFMLConfig.cmake (SFML >= 2.5) or alternatively set the SFML_ROOT variable to the root SFML folder (the directory that contains the include and lib folders). When you use SFML_ROOT when you compiled sfml yourself then you will have to watch out for three things:

You can now configure the settings. Set the CMAKE_BUILD_TYPE option either to “Debug” or to “Release” depending on the type of library you want. You should also look at the TGUI_SHARED_LIBS option, check it to build dynamic libraries (.dll files), uncheck it to build static libraries. This option has to match with the one chosen for SFML. CMake Configure

After setting the options like you want them you need to press Configure again. Now you should have reached the message “Configuring done” at the bottom. All you have to do now is press Generate. CMake Generate

Building the library

You are not done yet. CMake created a Visual Studio project in the build directory that has to be build first.

Open the tgui.sln file. You still have to manually change the Solution Configuration to match the CMAKE_BUILD_TYPE option from CMake.
Visual Studio Select Solution Configurations

Now hit “Build Solution” to build the TGUI libraries.
Build Solution

Once this is done, you will find the libraries inside the lib subdirectory of the build folder. To make it easier to use tgui in your project, you should probably copy the .lib (and .dll) files to a new “lib” folder in the TGUI root directory.

Using TGUI

Open the Project Properties.
Visual Studio Project Properties

In both debug and release mode, add the include and library directories.
Visual Studio Additional Include Directories Visual Studio Additional Library Directories

In both debug and release mode (this time seperately), you must add the library to link with. When you are only going to use one mode then you obviously don’t have to change the other one.
When linking statically you will need to link to tgui-s.lib and tgui-s-d.lib instead of tgui.lib and tgui-d.lib. The order of linking is also important: first sfml, then tgui.
Visual Studio Additional Dependencies (Release) Visual Studio Additional Dependencies (Debug)

When linking dynamically, don’t forget to copy the needed dlls to the directory where your compiled executable is.

You should now be able to use TGUI.