If you plan on shipping the generated project files with your source code, you will probably want to put each set of files into their own directory. For instance, put the Visual Studio 2002 files into a directory named build/vs2002, the Code::Blocks files into build/codeblocks, and so on.
The key to this is to set the location for both the solution and project to the current action (location is not inherited by the project). The example below does this, and also puts the compiled binaries and object files in the same directory. Note the parenthesis, which are required around variable and calculated values.
One complication is that the clean action can no longer deduce where the generated files live, so you will need to add code to remove them. The loop shown will look for and remove a subdirectory for each known action. I'm using some Premake internals here.
-- Action can be nil, for instance if you type `premake4 --help` -- You could also use path.join(_ACTION, "obj") instead, which handles nils local action = _ACTION or "" solution "MySolution" configurations { "Debug", "Release" } location ( action ) objdir ( action .. "/obj" ) configuration { "Debug" } targetdir ( action .. "/bin/debug" ) configuration { "Release" } targetdir ( action .. "/bin/release" ) project "MyProject" location ( action ) -- project configuration here if _ACTION == "clean" then for a in premake.action.each() do -- action trigger is "vs2008", "gmake", etc. os.rmdir(a.trigger) end end
Another approach is to put all of the project files directory into a container directory, such as build/. Cleanup is then easier, as it can just remove the container without worrying about what's inside.
local action = _ACTION or "" solution "MySolution" location ( "build/" .. action ) project "MyProject" location ( "build/" .. action ) if action == "clean" then os.rmdir("build") end
