I can't change my C++ version with from the Premake file (i'm using the MSVC toolchain) This is the lua file i'm running:
workspace "myname"
configurations{"Release", "Debug"}
platforms {"Win64", "Win32"}
project "myname"
kind "ConsoleApp"
language "C++"
files {"src/**.pch", "src/**.h", "src/**.cpp"} -- .hpp not included
buildoptions "--std=c++17"
filter "configurations:Debug"
defines { "DEBUG" }
symbols "On"
targetdir "bin/Debug"
filter "configurations:Release"
defines { "NDEBUG" }
optimize "On"
symbols "Off"
targetdir "bin/Release"
filter "platforms:Win64"
system "windows"
architecture "x86_64" --x64
filter "platforms:Win32"
system "windows"
architecture "x86"
It generates the solution, but the version is still the default one from vs (C++11)
--std=c++17
is specific to gcc/clang.
It would be /std=c++17
for msvc
so
filter "toolset:msc*"
buildoptions "/std=c++17"
filter "toolset:gcc* or clang*"
buildoptions "--std=c++17"
filter {}
Even like that, it would have caveas, as buildoptions
is not displayed correctly inside visual studio when there is a specific field (so, here, language would still be set to default and that entry would be in extra option), even if options is correctly used.
Fortunately, premake provides cppdialect
which handles that correctly:
cppdialect "c++17" -- apply to all toolsets and generators :-)