# Easily add [SFML 3](https://github.com/SFML/SFML) and [Dear ImGui](https://github.com/ocornut/imgui) to your premake5 projects
This repo contains the repositories for SFML, Dear ImGui, sfml-imgui, flac, vorbis, ogg, and freetype along with premake build scripts. This allows your project to build these libraries from source and statically link them to your executible. this makes developing on linux easier as most distros don't have SFML 3 in their package managers.

I have included `example-project.txt` and `example-workspace.txt` as examples on how to use this project ## How to integrate into your projects 1. Add the repository as a submodule and update its submodules
-(optional) replace `` with the path to the directory you want the repo to be cloned to, leaving this out will place this repo into `./imgui-sfml-premake` ``` git submodule add https://gitlab.com/JosephA1997/imgui-sfml-premake.git
git submodule update --init --recursive ``` 2. Add this to the top of the script that contains the workspace, replace 'path/to' with the directory that you cloned this repo to ```lua local ogg = require("path/to/ogg/build-ogg") local imgui = require("path/to/build-imgui") local sfml = require("path/to/sfml/build-sfml") local flac = require("path/to/flac/build-flac") local vorbis = require("path/to/vorbis/build-vorbis") local freetype = require("path/to/freetype/build-freetype") local imguisfml = require("path/to/imgui-sfml/build-imgui-sfml") ``` 3. In the workspace, add these lines ```lua filter"system:linux" pic"On" -- fix warning when statically linking filter"" externalwarnings "Off" --turn off build warnings created from sfml, imgui, and it's depedencies ``` 4. In the workspace, add these lines to add each dependency as its own project
`` - the directory where the static library will be placed
`` - the directory where object files will be placed ```lua ogg.generateproject(, ) sfml.generateproject(, ) flac.generateproject(, ) imgui.generateproject(, ) vorbis.generateproject(, ) freetype.generateproject(, ) imguisfml.generateproject(, ) ``` 5. At the top of each lua file containing a project that needs imgui or sfml, add these lines, replace 'path/to' with the directory that you cloned this repo to. if the project is in the same file as the workspace you can skip this ```lua local sfml = require("path/to/build-sfml") local imgui = require("path/to/build-imgui") local imguisfml = require("path/to/build-imgui-sfml") ``` 6. Inside of the projects that need sfml or imgui add these lines ```lua -- link order matters on GCC/Clang imgui.link() imguisfml.link() sfml.link() ``` ## Bundled Premake Info I have included premake5 executibles for windows and linux in the `premake5` directory. Inside you'll also find modules that add support for the ninja build system and to generate a compile_commands.json file for things like clangd

To use premake on windows ``` .\path\to\premake5\premake5.exe ``` And on linux ``` ./path/to/premake5/premake5 ``` To generate ninja build files, use the `premake-ninja` action ``` premake5 premake-ninja ``` To generate compile_commands.json, use the `ecc` action ``` premake5 ecc ```
Credits: * [SFML](https://github.com/SFML/SFML) (zlib/png license) Copyright (C) Laurent Gomila * [Dear ImGui](https://github.com/ocornut/imgui) (MIT License) Copyright (c) 2014-2025 Omar Cornut * [imgui-sfml](https://github.com/SFML/imgui-sfml/) (MIT License)
Copyright (c) 2016 Elias Daler
Copyright (c) 2014-2016 Omar Cornut and ImGui contributors
Copyright (c) 2014 Mischa Aster Alff * [FreeType](https://github.com/freetype/freetype) (The FreeType Project License) Portions of this software are copyright © 2025 The FreeType Project (www.freetype.org). All rights reserved. * [Ogg](https://github.com/xiph/ogg), [Vorbis](), [FLAC]() (BSD-3-Clause) Copyright (c) Xiph.Org Foundation