The Premake user guide has moved.

For Premake 4.x, the new user guide is here.

For Premake 5.x, the new user guide is here.

 


 

flags

The flags function specifies build flags to modify the compiling or linking process.

flags { "flag_list" }

If a project includes multiple calls to flags the lists are concatenated, in the order in which they appear in the script.

Updated information is available on the new Premake wiki.

Applies To

Solutions, projects, and configurations.

Parameters

flags_list is a list of string flag names; see below for a list of valid flags. The flag values are not case-sensitive. Flags that are not supported by a particular platform or toolset are ignored.

EnableSSE, EnableSSE2
Use the SSE instruction sets for floating point math.
ExtraWarnings
Sets the compiler's maximum warning level.
FatalWarnings
Treat warnings as errors.
FloatFast
Enable floating point optimizations at the expense of accuracy.
FloatStrict
Improve floating point consistency at the expense of performance.
Managed
Enable Managed C++ (.NET).
MFC
Enable support for Microsoft Foundation Classes.
NativeWChar, NoNativeWChar
Enable or disable support for the wchar data type. If no flag is specified, the toolset default will be used.
No64BitChecks
Disable 64-bit portability warnings.
NoEditAndContinue
Disable support for Visual Studio's Edit-and-Continue feature.
NoExceptions
Disable C++ exception support.
NoFramePointer
Disable the generation of stack frame pointers.
NoIncrementalLink
Disable support for Visual Studio's incremental linking feature.
NoImportLib
Prevent the generation of an import library for a Windows DLL.
NoManifest
Prevent the generation of a manifest for Windows executables and shared libraries.
NoMinimalRebuild
Disable Visual Studio's minimal rebuild feature.
NoPCH
Disable precompiled header support. If not specified, the toolset default behavior will be used. Also see pchheader and pchsource.
NoRTTI
Disable C++ runtime type information.
Optimize
Perform a balanced set of optimizations.
OptimizeSize
Optimize for the smallest file size.
OptimizeSpeed
Optimize for the best performance.
SEH
Enable structured exception handling.
StaticRuntime
Perform a static link against the standard runtime libraries.
Symbols
Generate debugging information.
Unicode
Enable Unicode strings. If not specified, the default toolset behavior is used.
Unsafe
Enable the use of unsafe code in .NET applications.
WinMain
Use WinMain() as the program entry point for Windows applications, rather than the default main().

If the existing flags are not sufficient, you can also pass tool-specific arguments directly to the compiler or linker using buildoptions and linkoptions.

Examples

A common configuration: enable debugging symbols in the Debug configuration, and optimize the Release configuration.

configuration "Debug"
  flags { "Symbols" }
 
configuration "Release"
  flags { "Optimize" }

You can specify multiple flags.

flags { "Symbols", "ExtraWarnings", "FatalWarnings" }