diff options
author | Brad King <brad.king@kitware.com> | 2022-07-22 19:34:14 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-07-25 18:27:24 (GMT) |
commit | ee047a68f27d9636d681d05252257da636b616a2 (patch) | |
tree | 6577a86cca6b947d63254e2d803ae550296b3c20 /Source/cmSystemTools.cxx | |
parent | 7ed8c2de6a755bc05d43ee1d5caf566b14c9209a (diff) | |
download | CMake-ee047a68f27d9636d681d05252257da636b616a2.zip CMake-ee047a68f27d9636d681d05252257da636b616a2.tar.gz CMake-ee047a68f27d9636d681d05252257da636b616a2.tar.bz2 |
cmSystemTools: Factor out method to get Windows OS version
Factor the implementation out of `cmGlobalGenerator`.
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 351386a..78d3ad9 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -107,6 +107,10 @@ # include <sys/utsname.h> #endif +#if defined(_MSC_VER) && _MSC_VER >= 1800 +# define CM_WINDOWS_DEPRECATED_GetVersionEx +#endif + namespace { cmSystemTools::InterruptCallback s_InterruptCallback; @@ -904,6 +908,40 @@ cmSystemTools::WindowsFileRetry cmSystemTools::GetWindowsDirectoryRetry() InitWindowsDirectoryRetry().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 std::string cmSystemTools::GetRealPathResolvingWindowsSubst( |