I needed to manage multiple projects in a single cross-platform-workspace with easy integration to clangd
I had multiple options:
- Makefile - Will not go back to those
- cmake - Industry standard, should've probably used that
- xmake - I didn't need an alternative to CMAKE
- premake - A meta build system with lua syntax (also like xmake, except more barebones)
Equipped with a new tool, I started migrating my previous project because recompilation targets were non-existent
This project is the result!
Each Project contains a premake5.lua
file, describing everything about its compilation/linking
There are 5 sub-projects available as reference/guiding points if you don't understand the Explanation below
- To add a project to compilation/linking:
- Add the path at
projects/lua
- Specify a LinkMyLibraryName function at the root
premake5.lua
file (seeLinkImGuiLibrary()
for more info) - Use
IncludeProjectHeaders(...)
&LinkMyLibraryName
in your library/executable' premake5.lua
- Add the path at
- To add a dependency to compilation/linking:
- Add your library to the folder
dependencies/
- Specify 2 functions at the root
premake5.lua
file:- LinkMyLibraryName
- IncludeProjectHeaders
- Use The defined functions in your library/executable' premake5.lua
- Add your library to the folder
- premake
- Working compiler toolchain, preferably clang
- Windows: You should use llvm
- Linux:
- Define these environment variables (in your PATH):
- LLVMInstallDir
- LLVMToolsVersion
- Powershell / Any Standard unix-shell
- with-subprojects - Includes ImGui, GLFW, glbinding, awc2 and a sample program at program/
- barebones - Executable-With-Library Samples, including reference premake files for:
- ImGui
- GLFW
- glbinding
- awc2
# If you want everything
git clone -b with-subprojects https://github.com/inonitz/premake5-workspace-template.git
# If you prefer to configure on your own
git clone -b barebones https://github.com/inonitz/premake5-workspace-template.git
# Don't forget to add your own remote repo
git remote set-url origin your_github_username/premake5-workspace-template
git remote -v
call premake5 help
in the cloned repo directory (.vscode/..)
premake5 --proj=program cleanproj
premake cleanall
premake cleancfgs
premake cleanclangd
premake export-compile-commands
premake --os=windows --arch=x86_64 --cc=clang gmake2
premake --os=windows --arch=x86_64 --cc=clang vs2022
premake --os=linux --arch=x86_64 --cc=clang gmake2
- Adding an option to delete files based on architecture (e.g
cleanarch --arch='x'
) - Optimization of execution time:
with-subprojects
branch- ~7sec [windows]
- ~4sec [wsl2]
barebones
branch- ~242ms [windows]
If you have a suggestion, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Distributed under the MIT License. See LICENSE
file for more information.
- Kumodatsu For the initial template repo
- Jarod42 For the Improvements branch of export-compile-commands
- Best-README