diff options
author | Joerg Bornemann <joerg.bornemann@digia.com> | 2013-10-29 16:09:18 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-31 12:33:55 +0100 |
commit | 392054d311ecc036397cb022b442fa27134a2d4b (patch) | |
tree | e7ac42d0920735bd68fd240893b323798d71cf94 /qmake/generators/win32/msvc_vcproj.cpp | |
parent | 67c9b5ad9f32bc0ef89a34f01b1f0602a4869865 (diff) |
fix VS version selection
On machines where multiple versions of VS are installed, the VS version
for the vc(x)proj generator is selected by the entries in the PATH
variable. The first VS installation that's found in PATH is used.
The former logic printed a warning if multiple VS installations were in
PATH and also fell back to the lowest version if a VS version was
registered with multiple install paths.
That's the case for VC 2012 express and prevented its usage.
Task-number: QTBUG-34357
Change-Id: Ia5c66a1aea0c40e4b7460b3aa6c7daee6673da44
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'qmake/generators/win32/msvc_vcproj.cpp')
-rw-r--r-- | qmake/generators/win32/msvc_vcproj.cpp | 47 |
1 files changed, 16 insertions, 31 deletions
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 8a5c5b7032..934902fd4a 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -124,17 +124,17 @@ DotNET which_dotnet_version() // Fallback to .NET 2002 current_version = NET2002; - QStringList warnPath; + const DotNetCombo *lowestInstalledVersion = 0; QHash<DotNET, QString> installPaths; int installed = 0; int i = 0; for(; dotNetCombo[i].version; ++i) { QString path = qt_readRegistryKey(HKEY_LOCAL_MACHINE, dotNetCombo[i].regKey); if (!path.isEmpty() && installPaths.value(dotNetCombo[i].version) != path) { - installPaths.insert(dotNetCombo[i].version, path); + lowestInstalledVersion = &dotNetCombo[i]; + installPaths.insert(lowestInstalledVersion->version, path); ++installed; - current_version = dotNetCombo[i].version; - warnPath += QString("%1").arg(dotNetCombo[i].versionStr); + current_version = lowestInstalledVersion->version; } } @@ -143,35 +143,20 @@ DotNET which_dotnet_version() // More than one version installed, search directory path QString paths = qgetenv("PATH"); - QStringList pathlist = paths.toLower().split(";"); - - i = installed = 0; - for(; dotNetCombo[i].version; ++i) { - QString productPath = qt_readRegistryKey(HKEY_LOCAL_MACHINE, dotNetCombo[i].regKey).toLower(); - if (productPath.isEmpty()) - continue; - QStringList::iterator it; - for(it = pathlist.begin(); it != pathlist.end(); ++it) { - if((*it).contains(productPath)) { - ++installed; - current_version = dotNetCombo[i].version; - warnPath += QString("%1 in path").arg(dotNetCombo[i].versionStr); - break; - } + const QStringList pathlist = paths.split(QLatin1Char(';')); + foreach (const QString &path, pathlist) { + for (i = 0; dotNetCombo[i].version; ++i) { + const QString productPath = installPaths.value(dotNetCombo[i].version); + if (productPath.isEmpty()) + continue; + if (path.startsWith(productPath, Qt::CaseInsensitive)) + return dotNetCombo[i].version; } } - switch(installed) { - case 1: - break; - case 0: - warn_msg(WarnLogic, "Generator: MSVC.NET: Found more than one version of Visual Studio, but" - " none in your path! Fallback to lowest version (%s)", warnPath.join(", ").toLatin1().data()); - break; - default: - warn_msg(WarnLogic, "Generator: MSVC.NET: Found more than one version of Visual Studio in" - " your path! Fallback to lowest version (%s)", warnPath.join(", ").toLatin1().data()); - break; - } + + warn_msg(WarnLogic, "Generator: MSVC.NET: Found more than one version of Visual Studio, but" + " none in your PATH. Falling back to lowest version (%s)", + qPrintable(lowestInstalledVersion->versionStr)); return current_version; #endif |