Skip to content
mba105 edited this page Sep 24, 2014 · 2 revisions

Home > [Scripting Reference](Scripting Reference) > solution


solution

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

#!lua
solution ("name")

Solutions are the top-level objects in a Premake build script, and are synonymous with a Visual Studio solution. Each solution contains one or more projects, which it turn contain the settings to generate a single binary target.

Parameters

name is a unique name for the solution. If a solution with the given name already exists, it is made active and returned. The solution name will be used as the file name of the generated solution file.

Return Value

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

Examples

Create a new solution named "MySolution".

#!lua
solution "MySolution"

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

#!lua
local sln = solution()

You can the global variable _SOLUTIONS to list out all of the currently defined solutions.

#!lua
for i, sln in ipairs(_SOLUTIONS) do
   print(sln.name)
end

The Solution Object

Each solution 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 solution object contains the following values.

basedir The directory where the project was original defined; acts as a root for relative paths.
configurations The list of valid configuration names.
blocks A list of configuration blocks.
language The solution language, if set.
location The output directory for the generated solution file.
name The name of the solution.
platforms A list of target platforms.
projects A list of projects contained by the solution.

Clone this wiki locally