
We’ve previously talked about a similar tool called Xmake. Premake is similar but automates project files for IDEs like Visual Studio and Xcode.
Premake is an open-source build automation tool that generates project files (such as Makefiles, Visual Studio, Xcode, etc.) from scripts written in Lua.
Premake automates project setup for multiple platforms and IDEs. It does not compile directly but generates the appropriate build files for tools like:
make (GNU)Visual StudioXcodeGNU MakeCode::BlocksCMake (indirectly, with wrappers)Most useful for cross-platform C/C++ projects.
Different versions require different configurations in premakeNUM.lua files—meaning premake4.lua is not compatible with premake5.lua.
On Windows, version 5 is available via WinGet. Just run:
winget install --id=Premake.Premake.5.Beta -e  However, not all GNU/Linux distros have the latest version in their repositories. For example, Ubuntu only offers version 4:
sudo apt install premake4  Alternatively, you can clone, compile, and install from source:
sudo apt install git build-essential  
git clone --depth=1 https://github.com/premake/premake-core.git  
cd premake-core  
make -f Bootstrap.mak linux  
sudo cp bin/release/premake5 /usr/local/bin/  
premake5 --version  The process may vary depending on the Premake version. Example for Premake4:
mkdir -p MyProject/src  
cd MyProject  
vim src/main.cpp # Hello, World!  Create a Premake4 file (e.g., vim premake4.lua):
solution "MyProject"  
   configurations { "Debug", "Release" }  
project "MyApp"  
   language "C++"  
   kind "ConsoleApp"  
   location "build"  
   files { "src/**.cpp", "include/**.hpp" }  
   includedirs { "include" }  
configuration "Debug"  
   targetdir "bin/Debug"  
configuration "Release"  
   targetdir "bin/Release"  Generate the files with:
premake4 gmake # Unix  Then compile and run:
make  
./bin/Debug/MyApp  Create a file named premake5.lua with the following content:
Basic example:
workspace "MyProject"  
   configurations { "Debug", "Release" }  
   language "C++"  
   location "build"  
project "MyApp"  
   kind "ConsoleApp"  
   files { "src/**.cpp", "include/**.h" }  
   includedirs { "include" }  
   targetdir "bin/%{cfg.buildcfg}"  Generate project files for an IDE:
premake5 vs2022       # Visual Studio 2022  
premake5 gmake2       # Makefiles for Linux  
premake5 xcode4       # Xcode  Compile:
.sln file and build.premake5 gmake2  
cd build  
make config=release  For more details, check these links and the help menu:
premake5 --help