From 5c50eeaffc334891af73f3a72557693c86ee380e Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 14 Mar 2019 13:14:23 -0400 Subject: VS: Fix x64 host recognition by x86 cmake process In commit 57e48f16f2 (VS: Add Visual Studio 16 2019 generator, 2019-01-09, v3.14.0-rc1~150^2) and commit 0fd742a6ff (VS: Teach VS 2019 generator to select host tools matching host arch, 2019-01-28, v3.14.0-rc1~63^2) we intended to select the `x64` target architecture and `x64` host tools by default on x64 host machines. Fix detection of a x64 host when CMake itself is a 32-bit x86 process. The KWSys SystemInformation `Is64Bits` member is not set correctly, which led to this bug. Pending investigation on the KWSys side, simply test ourselves via `IsWow64Process`. --- Source/cmGlobalVisualStudioVersionedGenerator.cxx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 4d74e32..f52abd0 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -18,8 +18,15 @@ #elif defined(_M_IA64) # define HOST_PLATFORM_NAME "Itanium" # define HOST_TOOLS_ARCH "" +#elif defined(_WIN64) +# define HOST_PLATFORM_NAME "x64" +# define HOST_TOOLS_ARCH "x64" #else -# include "cmsys/SystemInformation.hxx" +static bool VSIsWow64() +{ + BOOL isWow64 = false; + return IsWow64Process(GetCurrentProcess(), &isWow64) && isWow64; +} #endif static std::string VSHostPlatformName() @@ -27,8 +34,7 @@ static std::string VSHostPlatformName() #ifdef HOST_PLATFORM_NAME return HOST_PLATFORM_NAME; #else - cmsys::SystemInformation info; - if (info.Is64Bits()) { + if (VSIsWow64()) { return "x64"; } else { return "Win32"; @@ -41,8 +47,7 @@ static std::string VSHostArchitecture() #ifdef HOST_TOOLS_ARCH return HOST_TOOLS_ARCH; #else - cmsys::SystemInformation info; - if (info.Is64Bits()) { + if (VSIsWow64()) { return "x64"; } else { return "x86"; -- cgit v0.12