mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-01 11:50:11 -05:00
cmVSSetupHelper: Convert wide to narrow strings early
This commit is contained in:
+11
-12
@@ -54,9 +54,7 @@ const WCHAR* ComponentType = L"Component";
|
|||||||
|
|
||||||
std::string VSInstanceInfo::GetInstallLocation() const
|
std::string VSInstanceInfo::GetInstallLocation() const
|
||||||
{
|
{
|
||||||
std::string loc = cmsys::Encoding::ToNarrow(this->VSInstallLocation);
|
return this->VSInstallLocation;
|
||||||
cmSystemTools::ConvertToUnixSlashes(loc);
|
|
||||||
return loc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmVSSetupAPIHelper::cmVSSetupAPIHelper(unsigned int version)
|
cmVSSetupAPIHelper::cmVSSetupAPIHelper(unsigned int version)
|
||||||
@@ -161,7 +159,8 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo(
|
|||||||
if (FAILED(pInstance->GetInstallationVersion(&bstrVersion))) {
|
if (FAILED(pInstance->GetInstallationVersion(&bstrVersion))) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
vsInstanceInfo.Version = std::wstring(bstrVersion);
|
vsInstanceInfo.Version =
|
||||||
|
cmsys::Encoding::ToNarrow(std::wstring(bstrVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reboot may have been required before the installation path was created.
|
// Reboot may have been required before the installation path was created.
|
||||||
@@ -170,7 +169,9 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo(
|
|||||||
if (FAILED(pInstance->GetInstallationPath(&bstrInstallationPath))) {
|
if (FAILED(pInstance->GetInstallationPath(&bstrInstallationPath))) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
vsInstanceInfo.VSInstallLocation = std::wstring(bstrInstallationPath);
|
vsInstanceInfo.VSInstallLocation =
|
||||||
|
cmsys::Encoding::ToNarrow(std::wstring(bstrInstallationPath));
|
||||||
|
cmSystemTools::ConvertToUnixSlashes(vsInstanceInfo.VSInstallLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +252,7 @@ bool cmVSSetupAPIHelper::GetVSInstanceVersion(std::string& vsInstanceVersion)
|
|||||||
bool isInstalled = this->EnumerateAndChooseVSInstance();
|
bool isInstalled = this->EnumerateAndChooseVSInstance();
|
||||||
|
|
||||||
if (isInstalled) {
|
if (isInstalled) {
|
||||||
vsInstanceVersion = cmsys::Encoding::ToNarrow(chosenInstanceInfo.Version);
|
vsInstanceVersion = chosenInstanceInfo.Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isInstalled;
|
return isInstalled;
|
||||||
@@ -285,7 +286,7 @@ bool cmVSSetupAPIHelper::IsEWDKEnabled()
|
|||||||
bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
|
bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
|
||||||
{
|
{
|
||||||
bool isVSInstanceExists = false;
|
bool isVSInstanceExists = false;
|
||||||
if (chosenInstanceInfo.VSInstallLocation.compare(L"") != 0) {
|
if (chosenInstanceInfo.VSInstallLocation.compare("") != 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,10 +299,8 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
|
|||||||
if (envVSVersion.empty() || envVsInstallDir.empty())
|
if (envVSVersion.empty() || envVsInstallDir.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
chosenInstanceInfo.VSInstallLocation =
|
chosenInstanceInfo.VSInstallLocation = envVsInstallDir;
|
||||||
std::wstring(envVsInstallDir.begin(), envVsInstallDir.end());
|
chosenInstanceInfo.Version = envVSVersion;
|
||||||
chosenInstanceInfo.Version =
|
|
||||||
std::wstring(envVSVersion.begin(), envVSVersion.end());
|
|
||||||
chosenInstanceInfo.VCToolsetVersion = envVSVersion;
|
chosenInstanceInfo.VCToolsetVersion = envVSVersion;
|
||||||
chosenInstanceInfo.IsWin10SDKInstalled = true;
|
chosenInstanceInfo.IsWin10SDKInstalled = true;
|
||||||
chosenInstanceInfo.IsWin81SDKInstalled = !envWindowsSdkDir81.empty();
|
chosenInstanceInfo.IsWin81SDKInstalled = !envWindowsSdkDir81.empty();
|
||||||
@@ -329,7 +328,7 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring const wantVersion = std::to_wstring(this->Version) + L'.';
|
std::string const wantVersion = std::to_string(this->Version) + '.';
|
||||||
|
|
||||||
SmartCOMPtr<ISetupInstance> instance;
|
SmartCOMPtr<ISetupInstance> instance;
|
||||||
while (SUCCEEDED(enumInstances->Next(1, &instance, NULL)) && instance) {
|
while (SUCCEEDED(enumInstances->Next(1, &instance, NULL)) && instance) {
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ private:
|
|||||||
|
|
||||||
struct VSInstanceInfo
|
struct VSInstanceInfo
|
||||||
{
|
{
|
||||||
std::wstring VSInstallLocation;
|
std::string VSInstallLocation;
|
||||||
std::wstring Version;
|
std::string Version;
|
||||||
std::string VCToolsetVersion;
|
std::string VCToolsetVersion;
|
||||||
bool IsWin10SDKInstalled = false;
|
bool IsWin10SDKInstalled = false;
|
||||||
bool IsWin81SDKInstalled = false;
|
bool IsWin81SDKInstalled = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user