Windows: Set CMAKE_HOST_SYSTEM_VERSION with three components

Call GetVersionEx with OSVERSIONINFOEX instead of OSVERSIONINFO so that
we can get the dwBuildNumber as a third version component.
This commit is contained in:
Gilles Khouzam 2015-09-10 13:53:00 -07:00 committed by Brad King
parent 8e8824149f
commit 4734df5f79
1 changed files with 8 additions and 5 deletions

View File

@ -433,19 +433,22 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
{ {
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
/* Windows version number data. */ /* Windows version number data. */
OSVERSIONINFO osvi; OSVERSIONINFOEXW osviex;
ZeroMemory(&osvi, sizeof(osvi)); ZeroMemory(&osviex, sizeof(osviex));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); osviex.dwOSVersionInfoSize = sizeof(osviex);
#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); GetVersionExW((OSVERSIONINFOW*)&osviex);
#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 << osviex.dwMajorVersion << "."
<< osviex.dwMinorVersion << "."
<< osviex.dwBuildNumber;
windowsVersionString.str(); windowsVersionString.str();
mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION", mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION",
windowsVersionString.str().c_str()); windowsVersionString.str().c_str());