Gather additional info such as if VCToolset, WinSDKs are installed, location of VS and version information.
| 177 | // Gather additional info such as if VCToolset, WinSDKs are installed, location |
| 178 | // of VS and version information. |
| 179 | bool cmVSSetupAPIHelper::GetVSInstanceInfo( |
| 180 | SmartCOMPtr<ISetupInstance2> pInstance, VSInstanceInfo& vsInstanceInfo) |
| 181 | { |
| 182 | if (!pInstance) { |
| 183 | return false; |
| 184 | } |
| 185 | |
| 186 | InstanceState state; |
| 187 | if (FAILED(pInstance->GetState(&state))) { |
| 188 | return false; |
| 189 | } |
| 190 | |
| 191 | SmartBSTR bstrVersion; |
| 192 | if (FAILED(pInstance->GetInstallationVersion(&bstrVersion))) { |
| 193 | return false; |
| 194 | } |
| 195 | vsInstanceInfo.Version = |
| 196 | cmsys::Encoding::ToNarrow(std::wstring(bstrVersion)); |
| 197 | |
| 198 | // Reboot may have been required before the installation path was created. |
| 199 | SmartBSTR bstrInstallationPath; |
| 200 | if ((eLocal & state) == eLocal) { |
| 201 | if (FAILED(pInstance->GetInstallationPath(&bstrInstallationPath))) { |
| 202 | return false; |
| 203 | } |
| 204 | vsInstanceInfo.VSInstallLocation = |
| 205 | cmsys::Encoding::ToNarrow(std::wstring(bstrInstallationPath)); |
| 206 | cmSystemTools::ConvertToUnixSlashes(vsInstanceInfo.VSInstallLocation); |
| 207 | } |
| 208 | |
| 209 | // Check if a compiler is installed with this instance. |
| 210 | if (!LoadVSInstanceVCToolsetVersion(vsInstanceInfo)) { |
| 211 | return false; |
| 212 | } |
| 213 | |
| 214 | // Reboot may have been required before the product package was registered |
| 215 | // (last). |
| 216 | if ((eRegistered & state) == eRegistered) { |
| 217 | SmartCOMPtr<ISetupPackageReference> product; |
| 218 | if (FAILED(pInstance->GetProduct(&product)) || !product) { |
| 219 | return false; |
| 220 | } |
| 221 | |
| 222 | LPSAFEARRAY lpsaPackages; |
| 223 | if (FAILED(pInstance->GetPackages(&lpsaPackages)) || !lpsaPackages) { |
| 224 | return false; |
| 225 | } |
| 226 | |
| 227 | int lower = lpsaPackages->rgsabound[0].lLbound; |
| 228 | int upper = lpsaPackages->rgsabound[0].cElements + lower; |
| 229 | |
| 230 | IUnknown** ppData = (IUnknown**)lpsaPackages->pvData; |
| 231 | for (int i = lower; i < upper; i++) { |
| 232 | SmartCOMPtr<ISetupPackageReference> package = nullptr; |
| 233 | if (FAILED(ppData[i]->QueryInterface(IID_ISetupPackageReference, |
| 234 | (void**)&package)) || |
| 235 | !package) { |
| 236 | continue; |
no test coverage detected