Reputation: 1859
I need different build options for different compilers for a project I am working on. I am thinking of using the dofile keyword to include a different build configuration based on the compiler chosen when using premake5. How do I instruct premake5 to do something like (in pseudo code)
if gcc
dofile gcc.lua
else if vs2008
dofile vs2008.lua
else if vs2010
dofile vs2010.lua
else if vs2012
dofile vs2012.lua
else if vs2013
dofile vs2013.lua
else if vs2015
dofile vs2015.lua
etc.
Upvotes: 2
Views: 1159
Reputation: 4276
You can do what you suggest like this:
if _ACTION == "gmake" then
dofile "gcc.lua"
elseif _ACTION == "vs2008" then
dofile "vs2008.lua"
elseif ...
Or like this:
dofile(_ACTION .. ".lua")
But you probably want to do this instead:
filter { "action:gmake" }
define { "SOME_GMAKE_SYMBOLS" }
-- put your gmake configuration here
filter { "action:vs*" }
-- put your common VS configuration here
filter { "action:vs2008" }
define { "SOME_VS2008_SYMBOLS" }
-- put your VS2008 specific configuration here
filter { "action:vs*" }
-- put your common VS configuration here
-- and so on...
Upvotes: 3