diff options
author | Brad King <brad.king@kitware.com> | 2022-10-27 13:26:55 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-10-27 13:28:07 (GMT) |
commit | fdabb69e2e6e7046b83bd3de4e2e3e591a5d905d (patch) | |
tree | afc61f308cf39230307bf28dc07ce33d7f3078fb /Source | |
parent | 74057c72d656c029b9014029f147872bea3ff3cd (diff) | |
parent | 6eee8c9000cff8d5a5051b1bad28e611bc93db2d (diff) | |
download | CMake-fdabb69e2e6e7046b83bd3de4e2e3e591a5d905d.zip CMake-fdabb69e2e6e7046b83bd3de4e2e3e591a5d905d.tar.gz CMake-fdabb69e2e6e7046b83bd3de4e2e3e591a5d905d.tar.bz2 |
Merge topic 'vswhere-support-x86' into release-3.25
6eee8c9000 VS: Fix crash finding vswhere on 32-bit Windows
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7832
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmVSSetupHelper.cxx | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx index 1a3e72e..8764f21 100644 --- a/Source/cmVSSetupHelper.cxx +++ b/Source/cmVSSetupHelper.cxx @@ -300,13 +300,32 @@ bool cmVSSetupAPIHelper::IsEWDKEnabled() return false; } +#if !defined(CMAKE_BOOTSTRAP) +namespace { +std::string FindVsWhereCommand() +{ + std::string vswhere; + static const char* programFiles[] = { "ProgramFiles(x86)", "ProgramFiles" }; + for (const char* pf : programFiles) { + if (cmSystemTools::GetEnv(pf, vswhere)) { + vswhere += "/Microsoft Visual Studio/Installer/vswhere.exe"; + if (cmSystemTools::FileExists(vswhere)) { + return vswhere; + } + } + } + vswhere = "vswhere.exe"; + return vswhere; +} +} +#endif + bool cmVSSetupAPIHelper::EnumerateVSInstancesWithVswhere( std::vector<VSInstanceInfo>& VSInstances) { #if !defined(CMAKE_BOOTSTRAP) // Construct vswhere command to get installed VS instances in JSON format - std::string vswhereExe = getenv("ProgramFiles(x86)") + - std::string(R"(\Microsoft Visual Studio\Installer\vswhere.exe)"); + std::string vswhereExe = FindVsWhereCommand(); std::vector<std::string> vswhereCmd = { vswhereExe, "-format", "json" }; // Execute vswhere command and capture JSON output |