"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Source/cmVSSetupHelper.cxx" between
cmake-3.13.4.tar.gz and cmake-3.14.0-rc1.tar.gz

About: CMake is a cross-platform build system designed to build, test and package software. Release candidate.

cmVSSetupHelper.cxx  (cmake-3.13.4):cmVSSetupHelper.cxx  (cmake-3.14.0-rc1)
skipping to change at line 60 skipping to change at line 60
L"Microsoft.VisualStudio.Component.Windows81SDK"; L"Microsoft.VisualStudio.Component.Windows81SDK";
const WCHAR* ComponentType = L"Component"; const WCHAR* ComponentType = L"Component";
std::string VSInstanceInfo::GetInstallLocation() const std::string VSInstanceInfo::GetInstallLocation() const
{ {
std::string loc = cmsys::Encoding::ToNarrow(this->VSInstallLocation); std::string loc = cmsys::Encoding::ToNarrow(this->VSInstallLocation);
cmSystemTools::ConvertToUnixSlashes(loc); cmSystemTools::ConvertToUnixSlashes(loc);
return loc; return loc;
} }
cmVSSetupAPIHelper::cmVSSetupAPIHelper() cmVSSetupAPIHelper::cmVSSetupAPIHelper(unsigned int version)
: setupConfig(NULL) : Version(version)
, setupConfig(NULL)
, setupConfig2(NULL) , setupConfig2(NULL)
, setupHelper(NULL) , setupHelper(NULL)
, initializationFailure(false) , initializationFailure(false)
{ {
comInitialized = CoInitializeEx(NULL, 0); comInitialized = CoInitializeEx(NULL, 0);
if (SUCCEEDED(comInitialized)) { if (SUCCEEDED(comInitialized)) {
Initialize(); Initialize();
} else { } else {
initializationFailure = true; initializationFailure = true;
} }
skipping to change at line 91 skipping to change at line 92
} }
bool cmVSSetupAPIHelper::SetVSInstance(std::string const& vsInstallLocation) bool cmVSSetupAPIHelper::SetVSInstance(std::string const& vsInstallLocation)
{ {
this->SpecifiedVSInstallLocation = vsInstallLocation; this->SpecifiedVSInstallLocation = vsInstallLocation;
cmSystemTools::ConvertToUnixSlashes(this->SpecifiedVSInstallLocation); cmSystemTools::ConvertToUnixSlashes(this->SpecifiedVSInstallLocation);
chosenInstanceInfo = VSInstanceInfo(); chosenInstanceInfo = VSInstanceInfo();
return this->EnumerateAndChooseVSInstance(); return this->EnumerateAndChooseVSInstance();
} }
bool cmVSSetupAPIHelper::IsVS2017Installed() bool cmVSSetupAPIHelper::IsVSInstalled()
{ {
return this->EnumerateAndChooseVSInstance(); return this->EnumerateAndChooseVSInstance();
} }
bool cmVSSetupAPIHelper::IsWin10SDKInstalled() bool cmVSSetupAPIHelper::IsWin10SDKInstalled()
{ {
return (this->EnumerateAndChooseVSInstance() && return (this->EnumerateAndChooseVSInstance() &&
chosenInstanceInfo.IsWin10SDKInstalled); chosenInstanceInfo.IsWin10SDKInstalled);
} }
skipping to change at line 190 skipping to change at line 191
if (FAILED(pInstance->GetInstallationPath(&bstrInstallationPath))) { if (FAILED(pInstance->GetInstallationPath(&bstrInstallationPath))) {
return false; return false;
} else { } else {
vsInstanceInfo.VSInstallLocation = std::wstring(bstrInstallationPath); vsInstanceInfo.VSInstallLocation = std::wstring(bstrInstallationPath);
} }
} }
// Check if a compiler is installed with this instance. // Check if a compiler is installed with this instance.
{ {
std::string const vcRoot = vsInstanceInfo.GetInstallLocation(); std::string const vcRoot = vsInstanceInfo.GetInstallLocation();
std::string const vcToolsVersionFile = std::string vcToolsVersionFile =
vcRoot + "/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt"; vcRoot + "/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt";
if (!cmSystemTools::PathExists(vcToolsVersionFile)) {
// FIXME: VS 2019 Preview 2 installs the v142 toolset and does not
// provide the plain `Microsoft.VCToolsVersion.default.txt` that v141
// does. This should be fixed in preview 3 and this workaround can
// be dropped. Otherwise, we may need to switch to globbing.
vcToolsVersionFile = vcRoot +
"/VC/Auxiliary/Build/Microsoft.VCToolsVersion.v142.default.txt";
}
std::string vcToolsVersion; std::string vcToolsVersion;
cmsys::ifstream fin(vcToolsVersionFile.c_str()); cmsys::ifstream fin(vcToolsVersionFile.c_str());
if (!fin || !cmSystemTools::GetLineFromStream(fin, vcToolsVersion)) { if (!fin || !cmSystemTools::GetLineFromStream(fin, vcToolsVersion)) {
return false; return false;
} }
vcToolsVersion = cmSystemTools::TrimWhitespace(vcToolsVersion); vcToolsVersion = cmSystemTools::TrimWhitespace(vcToolsVersion);
std::string const vcToolsDir = vcRoot + "/VC/Tools/MSVC/" + vcToolsVersion; std::string const vcToolsDir = vcRoot + "/VC/Tools/MSVC/" + vcToolsVersion;
if (!cmSystemTools::FileIsDirectory(vcToolsDir)) { if (!cmSystemTools::FileIsDirectory(vcToolsDir)) {
return false; return false;
} }
skipping to change at line 270 skipping to change at line 279
vsToolsetVersion.clear(); vsToolsetVersion.clear();
bool isInstalled = this->EnumerateAndChooseVSInstance(); bool isInstalled = this->EnumerateAndChooseVSInstance();
if (isInstalled) { if (isInstalled) {
vsToolsetVersion = chosenInstanceInfo.VCToolsetVersion; vsToolsetVersion = chosenInstanceInfo.VCToolsetVersion;
} }
return isInstalled && !vsToolsetVersion.empty(); return isInstalled && !vsToolsetVersion.empty();
} }
bool cmVSSetupAPIHelper::IsEWDKEnabled()
{
std::string envEnterpriseWDK, envDisableRegistryUse;
cmSystemTools::GetEnv("EnterpriseWDK", envEnterpriseWDK);
cmSystemTools::GetEnv("DisableRegistryUse", envDisableRegistryUse);
if (!cmSystemTools::Strucmp(envEnterpriseWDK.c_str(), "True") &&
!cmSystemTools::Strucmp(envDisableRegistryUse.c_str(), "True")) {
return true;
}
return false;
}
bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance() bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
{ {
bool isVSInstanceExists = false; bool isVSInstanceExists = false;
if (chosenInstanceInfo.VSInstallLocation.compare(L"") != 0) { if (chosenInstanceInfo.VSInstallLocation.compare(L"") != 0) {
return true; return true;
} }
if (this->IsEWDKEnabled()) {
std::string envWindowsSdkDir81, envVSVersion, envVsInstallDir;
cmSystemTools::GetEnv("WindowsSdkDir_81", envWindowsSdkDir81);
cmSystemTools::GetEnv("VisualStudioVersion", envVSVersion);
cmSystemTools::GetEnv("VSINSTALLDIR", envVsInstallDir);
if (envVSVersion.empty() || envVsInstallDir.empty())
return false;
chosenInstanceInfo.VSInstallLocation =
std::wstring(envVsInstallDir.begin(), envVsInstallDir.end());
chosenInstanceInfo.Version =
std::wstring(envVSVersion.begin(), envVSVersion.end());
chosenInstanceInfo.VCToolsetVersion = envVSVersion;
chosenInstanceInfo.ullVersion = std::stoi(envVSVersion);
chosenInstanceInfo.IsWin10SDKInstalled = true;
chosenInstanceInfo.IsWin81SDKInstalled = !envWindowsSdkDir81.empty();
return true;
}
if (initializationFailure || setupConfig == NULL || setupConfig2 == NULL || if (initializationFailure || setupConfig == NULL || setupConfig2 == NULL ||
setupHelper == NULL) setupHelper == NULL)
return false; return false;
std::string envVSCommonToolsDir; std::string envVSCommonToolsDir;
std::string envVSCommonToolsDirEnvName =
"VS" + std::to_string(this->Version) + "0COMNTOOLS";
// FIXME: When we support VS versions beyond 2017, the version if (cmSystemTools::GetEnv(envVSCommonToolsDirEnvName.c_str(),
// to choose will be passed in by the caller. We need to map that envVSCommonToolsDir)) {
// to a per-version name of this environment variable.
if (cmSystemTools::GetEnv("VS150COMNTOOLS", envVSCommonToolsDir)) {
cmSystemTools::ConvertToUnixSlashes(envVSCommonToolsDir); cmSystemTools::ConvertToUnixSlashes(envVSCommonToolsDir);
} }
std::vector<VSInstanceInfo> vecVSInstances; std::vector<VSInstanceInfo> vecVSInstances;
SmartCOMPtr<IEnumSetupInstances> enumInstances = NULL; SmartCOMPtr<IEnumSetupInstances> enumInstances = NULL;
if (FAILED( if (FAILED(
setupConfig2->EnumInstances((IEnumSetupInstances**)&enumInstances)) || setupConfig2->EnumInstances((IEnumSetupInstances**)&enumInstances)) ||
!enumInstances) { !enumInstances) {
return false; return false;
} }
// FIXME: Add a way for caller to specify other versions. std::wstring const wantVersion = std::to_wstring(this->Version) + L'.';
std::wstring wantVersion = std::to_wstring(15) + L'.';
SmartCOMPtr<ISetupInstance> instance; SmartCOMPtr<ISetupInstance> instance;
while (SUCCEEDED(enumInstances->Next(1, &instance, NULL)) && instance) { while (SUCCEEDED(enumInstances->Next(1, &instance, NULL)) && instance) {
SmartCOMPtr<ISetupInstance2> instance2 = NULL; SmartCOMPtr<ISetupInstance2> instance2 = NULL;
if (FAILED( if (FAILED(
instance->QueryInterface(IID_ISetupInstance2, (void**)&instance2)) || instance->QueryInterface(IID_ISetupInstance2, (void**)&instance2)) ||
!instance2) { !instance2) {
instance = NULL; instance = NULL;
continue; continue;
} }
 End of changes. 9 change blocks. 
10 lines changed or deleted 51 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)