antibus
antibus

Reputation: 1092

premake4 out-of-source build

I'm still new to premake4. Before that, I used cmake and I liked the "out-of-source" generation of the building path. Unfortunately I didn't find a way to do this in premake4. I expected something like premake4 gmake ../path/to/src similar to cmake. But this didn't work.

I want to keep the source as clean as possible. Hence, suppose the source is at /home/workspace/src I would like to create a folder /home/workspace/build which contains all compiling/linking information and the executables.

I like premake4 because of the scripts which written in lua. But, if there is no way to generate out-of-source build paths I think I should stick to cmake.

Thus, do you know if it is possible to generate "out-of-source" build paths with premake4?

Upvotes: 2

Views: 431

Answers (1)

J. Perkins
J. Perkins

Reputation: 4276

In your project script, define a new command-line option, like so:

newoption {
    trigger = "to",
    value   = "path",
    description = "Set the output location for the generated files"
}

Then use it to set the location of the generated files:

solution "MySolution"
    location ( _OPTIONS["to"] )

Then you can use it:

$ premake4 --to=../path/to/generated/projects vs2010

You can also do a similar thing with the other output-related values, maybe something like:

local base = _OPTIONS["to"] or "."
targetdir ( path.join(base, "build") )
objdir ( path.join(base, "obj") )

Upvotes: 3

Related Questions