Merge topic 'fix-windows-version-detection'
d4736d53 Windows: Fix CMAKE_HOST_SYSTEM_VERSION on Windows >= 8.1 (#15674)
This commit is contained in:
commit
25ec835571
@ -14,6 +14,20 @@
|
|||||||
#if defined(_MSC_VER) && _MSC_VER >= 1800
|
#if defined(_MSC_VER) && _MSC_VER >= 1800
|
||||||
# define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
|
# define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
|
||||||
#endif
|
#endif
|
||||||
|
typedef struct {
|
||||||
|
ULONG dwOSVersionInfoSize;
|
||||||
|
ULONG dwMajorVersion;
|
||||||
|
ULONG dwMinorVersion;
|
||||||
|
ULONG dwBuildNumber;
|
||||||
|
ULONG dwPlatformId;
|
||||||
|
WCHAR szCSDVersion[128];
|
||||||
|
USHORT wServicePackMajor;
|
||||||
|
USHORT wServicePackMinor;
|
||||||
|
USHORT wSuiteMask;
|
||||||
|
UCHAR wProductType;
|
||||||
|
UCHAR wReserved;
|
||||||
|
} CMRTL_OSVERSIONINFOEXW;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "cmGlobalGenerator.h"
|
#include "cmGlobalGenerator.h"
|
||||||
@ -433,23 +447,45 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
|
|||||||
if (!mf->GetDefinition("CMAKE_SYSTEM"))
|
if (!mf->GetDefinition("CMAKE_SYSTEM"))
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
/* Windows version number data. */
|
CMRTL_OSVERSIONINFOEXW osviex;
|
||||||
OSVERSIONINFO osvi;
|
ZeroMemory(&osviex, sizeof(osviex));
|
||||||
ZeroMemory(&osvi, sizeof(osvi));
|
osviex.dwOSVersionInfoSize = sizeof(osviex);
|
||||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
|
||||||
|
typedef LONG (FAR WINAPI *cmRtlGetVersion)(CMRTL_OSVERSIONINFOEXW*);
|
||||||
|
cmRtlGetVersion rtlGetVersion = reinterpret_cast<cmRtlGetVersion>(
|
||||||
|
GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "RtlGetVersion"));
|
||||||
|
if (rtlGetVersion && rtlGetVersion(&osviex) == 0)
|
||||||
|
{
|
||||||
|
std::ostringstream windowsVersionString;
|
||||||
|
windowsVersionString << osviex.dwMajorVersion << "."
|
||||||
|
<< osviex.dwMinorVersion << "."
|
||||||
|
<< osviex.dwBuildNumber;
|
||||||
|
windowsVersionString.str();
|
||||||
|
mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION",
|
||||||
|
windowsVersionString.str().c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// RtlGetVersion failed, so use the deprecated GetVersionEx function.
|
||||||
|
/* Windows version number data. */
|
||||||
|
OSVERSIONINFO osvi;
|
||||||
|
ZeroMemory(&osvi, sizeof(osvi));
|
||||||
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
|
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
|
||||||
# pragma warning (push)
|
# pragma warning (push)
|
||||||
# pragma warning (disable:4996)
|
# pragma warning (disable:4996)
|
||||||
#endif
|
#endif
|
||||||
GetVersionEx (&osvi);
|
GetVersionEx (&osvi);
|
||||||
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
|
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
|
||||||
# pragma warning (pop)
|
# pragma warning (pop)
|
||||||
#endif
|
#endif
|
||||||
std::ostringstream windowsVersionString;
|
std::ostringstream windowsVersionString;
|
||||||
windowsVersionString << osvi.dwMajorVersion << "." << osvi.dwMinorVersion;
|
windowsVersionString << osvi.dwMajorVersion << "."
|
||||||
windowsVersionString.str();
|
<< osvi.dwMinorVersion;
|
||||||
mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION",
|
windowsVersionString.str();
|
||||||
windowsVersionString.str().c_str());
|
mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION",
|
||||||
|
windowsVersionString.str().c_str());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
// Read the DetermineSystem file
|
// Read the DetermineSystem file
|
||||||
std::string systemFile = mf->GetModulesFile("CMakeDetermineSystem.cmake");
|
std::string systemFile = mf->GetModulesFile("CMakeDetermineSystem.cmake");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user