premake-core
premake-core copied to clipboard
Applying a "defines" using "newoption" with value description allowed pairs and then configuration by value
What are you trying to do? Specify a compiler defines based upon a newoption configuration value.
What problem are you having? When the configuration filter is obtained from a defined list of allowed values, the resulting generated makefiles do not apply the defines command.
What have you tried so far?
newoption {
trigger = "gfxapi",
value = "API",
description = "Select graphics API.",
default = "vulkan",
allowed = {
{ "vulkan", "Vulkan" }
}
}
configuration "vulkan"
defines {
"VULKAN"
}
What version of Premake are you using? premake5 5.0.0-alpha15
Anything else we should know? For now, I alternatively got it to work, albeit not as desired with (does not force exclusive flag choice):
newoption {
trigger = "vulkan",
description = "Render with vulkan"
}
configuration "vulkan"
defines {
"VULKAN"
}
It also seems this configuration specifications are not actually being applied, as I found by trying from I the given example from command line arguments with links { "this" }. Apologies if the issue is obvious.
Note that I am linking this premake5 main workspace file with two other project files where I want the defines to be included. I assumed this is how it would work from the wiki and the behavior of the cousin alternative from above.
Status It appears I needed to use configuration "gfxapi=vulkan". This was not obvious to me from the wiki example and instructions, I just found this from trial and error before checking the source code. I believe this should be updated on the aformementioned command line arguments wiki page for premake unless this is a premake5 alpha specific issue. Below is an example of a working configuration filter for my case:
newoption {
trigger = "gfxapi",
value = "API",
description = "Choose a particular 3D API for rendering",
default = "vulkan",
allowed = {
{ "vulkan", "Vulkan" }
}
}
configuration "gfxapi=vulkan"
defines { "VULKAN" }
links { "glfw" }
FYI, configuration
is deprecated, you should use filter
instead. The syntax you discovered is documented on the filter
wiki page, the command line arguments docs need to be updated to not use configuration
as well as how to filter
by values. Thanks for pointing this out!
FYI,
configuration
is deprecated, you should usefilter
instead. The syntax you discovered is documented on thefilter
wiki page, the command line arguments docs need to be updated to not useconfiguration
as well as how tofilter
by values. Thanks for pointing this out!
No problem. Thanks for letting me know I've adjusted my premake file with no issues!
I'm going to reopen this so that we know to update the wiki page for command line arguments.