mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-08 08:40:48 +00:00
cmSystemTools: Factor out method to get Windows OS version
Factor the implementation out of `cmGlobalGenerator`.
This commit is contained in:
@@ -49,6 +49,7 @@
|
|||||||
#include "cmState.h"
|
#include "cmState.h"
|
||||||
#include "cmStateDirectory.h"
|
#include "cmStateDirectory.h"
|
||||||
#include "cmStateTypes.h"
|
#include "cmStateTypes.h"
|
||||||
|
#include "cmSystemTools.h"
|
||||||
#include "cmValue.h"
|
#include "cmValue.h"
|
||||||
#include "cmVersion.h"
|
#include "cmVersion.h"
|
||||||
#include "cmWorkingDirectory.h"
|
#include "cmWorkingDirectory.h"
|
||||||
@@ -62,10 +63,6 @@
|
|||||||
# include "cmQtAutoGenGlobalInitializer.h"
|
# include "cmQtAutoGenGlobalInitializer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1800
|
|
||||||
# define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const std::string kCMAKE_PLATFORM_INFO_INITIALIZED =
|
const std::string kCMAKE_PLATFORM_INFO_INITIALIZED =
|
||||||
"CMAKE_PLATFORM_INFO_INITIALIZED";
|
"CMAKE_PLATFORM_INFO_INITIALIZED";
|
||||||
|
|
||||||
@@ -616,34 +613,12 @@ void cmGlobalGenerator::EnableLanguage(
|
|||||||
// what platform we are running on
|
// what platform we are running on
|
||||||
if (!mf->GetDefinition("CMAKE_SYSTEM")) {
|
if (!mf->GetDefinition("CMAKE_SYSTEM")) {
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
/* Windows version number data. */
|
cmSystemTools::WindowsVersion windowsVersion =
|
||||||
OSVERSIONINFOEXW osviex;
|
cmSystemTools::GetWindowsVersion();
|
||||||
ZeroMemory(&osviex, sizeof(osviex));
|
|
||||||
osviex.dwOSVersionInfoSize = sizeof(osviex);
|
|
||||||
|
|
||||||
# ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
|
|
||||||
# pragma warning(push)
|
|
||||||
# ifdef __INTEL_COMPILER
|
|
||||||
# pragma warning(disable : 1478)
|
|
||||||
# elif defined __clang__
|
|
||||||
# pragma clang diagnostic push
|
|
||||||
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
||||||
# else
|
|
||||||
# pragma warning(disable : 4996)
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
GetVersionExW((OSVERSIONINFOW*)&osviex);
|
|
||||||
# ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
|
|
||||||
# ifdef __clang__
|
|
||||||
# pragma clang diagnostic pop
|
|
||||||
# else
|
|
||||||
# pragma warning(pop)
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
std::ostringstream windowsVersionString;
|
std::ostringstream windowsVersionString;
|
||||||
windowsVersionString << osviex.dwMajorVersion << "."
|
windowsVersionString << windowsVersion.dwMajorVersion << "."
|
||||||
<< osviex.dwMinorVersion << "."
|
<< windowsVersion.dwMinorVersion << "."
|
||||||
<< osviex.dwBuildNumber;
|
<< windowsVersion.dwBuildNumber;
|
||||||
mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION", windowsVersionString.str());
|
mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION", windowsVersionString.str());
|
||||||
#endif
|
#endif
|
||||||
// Read the DetermineSystem file
|
// Read the DetermineSystem file
|
||||||
|
|||||||
@@ -107,6 +107,10 @@
|
|||||||
# include <sys/utsname.h>
|
# include <sys/utsname.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && _MSC_VER >= 1800
|
||||||
|
# define CM_WINDOWS_DEPRECATED_GetVersionEx
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
cmSystemTools::InterruptCallback s_InterruptCallback;
|
cmSystemTools::InterruptCallback s_InterruptCallback;
|
||||||
@@ -904,6 +908,40 @@ cmSystemTools::WindowsFileRetry cmSystemTools::GetWindowsDirectoryRetry()
|
|||||||
InitWindowsDirectoryRetry().Retry;
|
InitWindowsDirectoryRetry().Retry;
|
||||||
return retry;
|
return retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmSystemTools::WindowsVersion cmSystemTools::GetWindowsVersion()
|
||||||
|
{
|
||||||
|
/* Windows version number data. */
|
||||||
|
OSVERSIONINFOEXW osviex;
|
||||||
|
ZeroMemory(&osviex, sizeof(osviex));
|
||||||
|
osviex.dwOSVersionInfoSize = sizeof(osviex);
|
||||||
|
|
||||||
|
# ifdef CM_WINDOWS_DEPRECATED_GetVersionEx
|
||||||
|
# pragma warning(push)
|
||||||
|
# ifdef __INTEL_COMPILER
|
||||||
|
# pragma warning(disable : 1478)
|
||||||
|
# elif defined __clang__
|
||||||
|
# pragma clang diagnostic push
|
||||||
|
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
# else
|
||||||
|
# pragma warning(disable : 4996)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
GetVersionExW((OSVERSIONINFOW*)&osviex);
|
||||||
|
# ifdef CM_WINDOWS_DEPRECATED_GetVersionEx
|
||||||
|
# ifdef __clang__
|
||||||
|
# pragma clang diagnostic pop
|
||||||
|
# else
|
||||||
|
# pragma warning(pop)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
WindowsVersion result;
|
||||||
|
result.dwMajorVersion = osviex.dwMajorVersion;
|
||||||
|
result.dwMinorVersion = osviex.dwMinorVersion;
|
||||||
|
result.dwBuildNumber = osviex.dwBuildNumber;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string cmSystemTools::GetRealPathResolvingWindowsSubst(
|
std::string cmSystemTools::GetRealPathResolvingWindowsSubst(
|
||||||
|
|||||||
@@ -509,6 +509,14 @@ public:
|
|||||||
};
|
};
|
||||||
static WindowsFileRetry GetWindowsFileRetry();
|
static WindowsFileRetry GetWindowsFileRetry();
|
||||||
static WindowsFileRetry GetWindowsDirectoryRetry();
|
static WindowsFileRetry GetWindowsDirectoryRetry();
|
||||||
|
|
||||||
|
struct WindowsVersion
|
||||||
|
{
|
||||||
|
unsigned int dwMajorVersion;
|
||||||
|
unsigned int dwMinorVersion;
|
||||||
|
unsigned int dwBuildNumber;
|
||||||
|
};
|
||||||
|
static WindowsVersion GetWindowsVersion();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Get the real path for a given path, removing all symlinks.
|
/** Get the real path for a given path, removing all symlinks.
|
||||||
|
|||||||
Reference in New Issue
Block a user