Search code examples
premake

premake: how to get a list of the defined configurations?


ie, I'd like a hypothetical function get_configurations() that would let me do something like this in my premake5.lua:

workspace "myworkspace"
    configurations { "debug", "release" }
project "myproject"
    configurations { "projconfig" }
    for _, cfg in ipairs(get_configurations()) do
        print(cfg)
    end

...and have it output:

debug
release
projconfig

Is this possible? I saw that there is premake.configset, but it's not clear how to use it...


Solution

  • No, that is not possible. In your simple example it looks easy, but in larger projects there may be many considerations that go into deciding what values end up in that list. It could be filtered by target platform, or toolset, or any number of other variables. Some later block may remove a value that was set earlier. The actual list can't be determined until after all scripts have been run and the final configuration is compiled for export.

    However, Premake is just Lua, so you can always define a list of configurations and associate it with a variable, or wrap your settings up in a function and pass in the values.