premake / premake-core

Premake
https://premake.github.io/
BSD 3-Clause "New" or "Revised" License
3.23k stars 619 forks source link

Default Generator #1479

Open Enhex opened 4 years ago

Enhex commented 4 years ago

What problem will this solve? I automatically call Premake on several projects, and currently I have the generator hardcoded into the script. Problem is I want to use a different generator per platform, or switch to a different generator, or use the latest Visual Studio generator.

What might be a solution? two part:

  1. option to set a system wide default generator that will be used when no generator is explicitly specified.
  2. "vs-latest" generator option that automatically finds and uses the latest Vistual Studio version that's installed.

What other alternatives have you already considered? might be possible to do dirty hacks like using environment variables.

starkos commented 4 years ago

You can actually do this yourself, with no changes to Premake, by testing the host and calling vswhere from your system script.

Untested, but should be pretty close:

if not _ACTION then
   if os.host() == 'windows' then
      local ver, err = os.outputof('"C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe" -latest -property productId')
      _ACTION = 'vs' .. ver
   elseif os.host() == 'macox' then
      _ACTION = 'xcode4'
   end
end

I'll leave this marked as Open since a "vs-latest" action could be useful. Not something that I'll be likely to get to, but would be happy to approve a pull request to add it!