project

The project function creates a new project and makes it active.

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.

Parameters

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.

Return Value

The function returns the active project object; see The Project Object below for more information on the structure of this object.

See Also

solution

Examples

Create a new project named "MyProject". Note that a solution must exist to contain the project. The indentation is for readability and is optional.

solution "MySolution"
   configuration { "Debug", "Release" }
 
   project "MyProject"

You can retrieve the currently active project object by calling project with no parameters.

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.

local prjs = solution().projects
for i, prj in ipairs(prjs) do
   print(prj.name)
end

The Project Object

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.

This

local prj = project()

does not seem to work in Premake 4.3 anymore. It always returns nil. But configuration() returns the configuration.