Premake Quickstart Guide - UND-Robotic-Mining-Team/Master-Guide GitHub Wiki
Premake is an awesome tool based on Lua which lets you configure your projects to compile 100% of the time on any platform with any tools.
Here's a sample Premake file to start with:
#!lua
solution "rover-control"
configurations { "Debug", "Release" }
files {
"../src/*.cpp",
"../include/*.h"
}
includedirs {
"../include"
}
project "rover-control"
kind "ConsoleApp"
language "C++"
files { "**.h", "**.cpp" }
configuration "Debug"
defines { "DEBUG" }
flags { "Symbols" }
targetdir "../build/Debug"
configuration "Release"
defines { "NDEBUG" }
flags { "Optimize" }
targetdir "../build/Release"
As you can see, it's somewhat reasonably simple. Note that this configuration assumes the following folder structure.
Project Organization
.
├── build # Compiled files (alternatively `dist`)
├── docs # Documentation files (alternatively `doc`)
├── src # Source files (alternatively `lib` or `app`)
├── include # Header files
├── test # Automated tests (alternatively `spec` or `tests`)
├── tools # Tools and utilities (premake4.lua should be in here)
├── LICENSE
└── README.md
This means that your top-level folder doesn't get cluttered with a bunch of build artefacts.
To run Premake on linux is simple: go to the folder where the file is (i.e. in this case $(ProjectDir)/tools) and simply run "premake4 gmake". Then, run "make" and "make clean" to build your project with the default presets.
On Windows, it can be a bit more involved. Let's say you download Premake4 and it's saved as premake4.exe in the folder above your project. That is, you have the following:
├── premake4.exe
└── .
├── tools # Tools and utilities (premake4.lua should be in here)
└──── premake4.lua
├── LICENSE
└── README.md
...
Thus, you need to open your "tools" folder in Powershell (hold shift and right click in file explorer, then select "open in powershell" should do the trick), and then you need to run ..\..\premake4.exe vs2013
for example, to generate Visual Studio 2013 files. These project files should be ready to compile and do development work with, assuming the last person set the project up properly.
Alternatively, you can simply add premake4.exe to a folder of your choosing and edit your environment variables to have it included in your path, so you only need to run "premake4 vs2013" or similar.