premake-core icon indicating copy to clipboard operation
premake-core copied to clipboard

systemversion "min:max" doesn't seem to work correctly

Open aik6980 opened this issue 8 years ago • 6 comments

Hi, i'm using premake5, here when I tried to use systemversion function with min:max syntax, somehow the min number is always been selected even though my machine doesn't have winsdk 10.0.10586.0 installed (I do have 10.0.14393.0)

systemversion "10.0.10586.0:10.0.14393.0"

I'm trying to generated projects for VS2015

thanks! Aik

aik6980 avatar Dec 16 '16 06:12 aik6980

Off the top of my head, I think max system version is only supported for macOS. Not sure how we would even do it for Windows? Does it have a setting like that?

starkos avatar Dec 16 '16 19:12 starkos

This has been added I believed from this thread? https://github.com/premake/premake-core/pull/450

After looking at the code, I think this API seems to always pick the "min" instead of the latest version installed on the machine.

I found the same feature people asked on this same feature on CMake forum and the way to get the latest version of WINSDK is to read it from Window Registry key, https://public.kitware.com/Bug/view.php?id=15670

aik6980 avatar Dec 17 '16 11:12 aik6980

That works if you run Premake on the same machine you build from, but that isn't always the case! We could perhaps add an API to expose that value though, and then you could use it to set the version, maybe like…

systemversion(os.winSdkVersion())

…or something.

starkos avatar Dec 17 '16 19:12 starkos

systemversion(os.winSdkVersion())

this looks like a good solution, yeah.

aik6980 avatar Dec 18 '16 08:12 aik6980

Now with os.getWindowsRegistry you're able to supply this yourself:

function os.winSdkVersion()
	local reg_arch = iif( os.is64bit(), "\\Wow6432Node\\", "\\" )

	local sdk_verison = os.getWindowsRegistry( "HKLM:SOFTWARE" .. reg_arch .."Microsoft\\Microsoft SDKs\\Windows\\v10.0\\ProductVersion" )
	if sdk_verison ~= nil then return sdk_version end

	-- add more versions here ( "v8.1", "v7.1A" )
end

for example I'm using this:

filter					"system:windows"
	defines					{ "_WINDOWS" }
	if os.getversion().majorversion == 10 then
		local sRegArch = iif( os.is64bit(), "\\Wow6432Node\\", "\\" )
		local sWin10SDK = os.getWindowsRegistry( "HKLM:SOFTWARE" .. sRegArch .. "Microsoft\\Microsoft SDKs\\Windows\\v10.0\\ProductVersion" )

		-- apparently it needs an extra ".0" to be recognized by VS
		if sWin10SDK ~= nil then systemversion( sWin10SDK .. ".0" ) end
	end

neico avatar Mar 08 '17 11:03 neico

Any word on when this will be fixed? I am running into a similar issue where the Target Platform Min. Version field is not being set in Visual Studio 2019 when using systemversion ("10.0.18362.0:latest") and as a result, WindowsTargetPlatformMinVersion is not being set inside the project file.

GCourtney27 avatar Jul 10 '21 19:07 GCourtney27