-
Notifications
You must be signed in to change notification settings - Fork 21
project
Home > [Scripting Reference](Scripting Reference) > project
The project function creates a new project and makes it active.
#!lua
project ("name")
Projects contain all of the settings necessary to build a single binary target, and are synonymous with a Visual Studio project. These settings include the list of source code files, the programming language used by those files, compiler flags, include directories, and which libraries to link against.
Every project belongs to a solution.
name is a unique name for the project. If a project with the given name already exists, it is made active and returned. The project name will be used as the file name of the generated solution file.
The function returns the active project object; see The Project Object below for more information on the structure of this object.
solution
Create a new project named "MyProject". Note that a solution must exist to contain the project. The indentation is for readability and is optional.
#!lua
solution "MySolution"
configurations { "Debug", "Release" }
project "MyProject"
You can retrieve the currently active project object by calling project with no parameters.
#!lua
local prj = project()
You can retrieve the list of projects associated with a solution using the projects field on the solution object, which may then be iterated over.
#!lua
local prjs = solution().projects
for i, prj in ipairs(prjs) do
print(prj.name)
end
Each project is represented in Lua as a table of key-value pairs. Unless you really know what you are doing, you should treat this object as read-only, and use the Premake API to make any changes.
The project object contains the following values.
basedir | The directory where the project was original defined; acts as a root for relative paths. |
blocks | A list of configuration blocks. |
language | The project language, if set. |
location | The output directory for the generated project file. |
name | The name of the project. |
solution | The solution which contains the project. |
uuid | The project's unique identifier. |