buildoptions

The buildoptions function passes arguments directly to the compiler command line without translation.

buildoptions { "options" }

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

Applies To

Solutions, projects, and configurations.

Parameters

options is a list of compiler flags and options, specific to a particular compiler.

Examples

Use pkg-config style configuration when building on Linux with GCC. Build options are always compiler specific and should be targeted to a particular toolset.

configuration { "linux", "gmake" }
  buildoptions { "`wx-config --cxxflags`", "-ansi", "-pedantic" }

I think given example is not a recommended practice:

  • Magic quotes ` ` are shell-dependent
  • wx-config is called each time compiler is invoked which will slow down build

I think it would be better to use the next code:

configuration { "linux", "gmake" }
   buildoptions { os.outputof("wx-config --cxxflags"), "-ansi", "-pedantic" } --evaluated once

UPD: Realized that this change will require running premake4 on user's system. We probably need custom Makefile variable to cache such things.

It seems with lua you have to pass in your target at solution generation time and then use platform specific notation (unlike CMake). I could be wrong here, but so far that is my observation.