Solutions and Projects

Starting with Premake 4.0 I am following the Visual Studio naming conventions for build components. For those of you unfamiliar with Visual Studio I will try to provide the synonyms used by other toolsets; if I miss any let me know and I'll add them.

Solutions

At the top level of every build is a solution, acting as a container and meta-project (other tools use the term workspace). Solutions define a common set of configurations and encapsulate one or more projects (see below). You can define build-wide settings at the solution level; these will apply to all of the projects contained by that solution.

Solutions are defined using the solution function. Most builds will need only a single solution, but you are free to create more if needed. Configurations are specified using the configurations function; see the next section for more information.

solution "MySolution"
  configurations { "Debug", "Release" }

The solution name, provided as a parameter to the function, is used as the file name of the generated solution file. So avoid special characters; spaces are okay.

Projects

The primary purpose of a solution is to act as a container for projects. A project lists the settings and source files needed to build one binary target. Just about every IDE uses the term "project" for this. In the world of Make, you can think of projects as a makefile for one particular library or executable; a solution is a meta-makefile that calls each project as needed.

Projects are defined using the project function. You must create a solution and list the available configurations before creating the first project.

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

The project name, like the solution name, is used as the file name for the generated project file so avoid special characters.

Each project specifies a kind which determines what kind of output is generated, such as a console or windowed executable, or a shared or static library. The kind function is used to specify this value.

Each project also specifies which programming language it uses, such as C++ or C#. The language function is used to set this value.

project "MyProject"
  kind "ConsoleApp"
  language "C++"

Locations

By default, Premake will place generated solution and project files in the same directory as the script which defined them. If your Premake script is in C:\Code\MyProject then the generated files will also be in C:\Code\MyProject.

You can change the output location using the location function.

solution "MySolution"
  configurations { "Debug", "Release" }
  location "build"
 
project "MyProject"
  location "build"

The path provided for location should be specified relative to the script file. Using the example and script above, the generated files will be placed in C:\Code\MyProject\build.

FYI, in Xcode's terminology, solutions are called "Projects" and projects are called "Targets".

@Anonymous: That would be correct if Xcode properly supported target dependencies. Since it doesn't, there really is no analogy for "solution".

Target dependencies in Xcode have always worked for me. What is missing?