Reputation: 753
I have tried using the "C++11" premake
flag, to get the GNU C++ compiler to do a C++11 compilation.
However, this flag is not recognized and I get the message "invalid flag".
The statement I used in the premake
lua script is the following, at either the project or configuration level:
flags {"C++11"}
I am using premake4
on Windows 10 through MSYS
. The g++ version is 4.8.1 and supports C++11. (When I use make
directly, I am passing the c++11 flag as a compilation option to the compiler and it works.)
How can I proceed to get a C++11 compilation using premake
?
Upvotes: 3
Views: 4160
Reputation: 2250
For windows build you do not need to specify anything since the vs version implies support of the required standard, so premake5.exe vs2012
or later ver enough.
For linux or macOS use
buildoptions "-std=c++11"
Upvotes: 0
Reputation: 753
Well, I have tried a few things and I have a solution. It works.
1) First, with premake4
, the flags {"C++11"}
statement doesn't appear to work. What I mean is, on premake4
, the C++11
flag isn't recognized. Note that the flags
statements itself is valid on premake4
but (apparently) not the C++11
flag .
2) On premake5
, the flags
statement itself has been deprecated. So you can't use flags {"C++11"}
on premake5
. Instead, use the cppdialect "C++11"
statement. I used it within the configuration
blocks.
3) Now, you can issue the statement to create the makefiles
using premake5
. Eg:
premake5 --file=premake-lua-scriptname.lua gmake
4) Later, when you run the generated makefiles
, you will find the binary created, by default, in the bin
subdirectory subordinate to the dir containing the premake5 lua script. Take my suggestion and override this default to have it created in the same dir as the lua script. (I'll explain why below.) You override this default using the targetdir
function, which can be issued at the project level. Eg:
targetdir "."
5) Note that the current (alpha12) release of premake5
doesn't support the clean
action. To invoke the clean
action, you will have to use premake4
. That's why I suggested creating the binary in the default dir. premake4
then cleans it by default.
All this works. However, is there a better solution?
Upvotes: 1