diff --git a/src/plugins/projectexplorer/toolchain.cpp b/src/plugins/projectexplorer/toolchain.cpp index 523689e57b65fe78d64aa314268da9bfdbb9feb5..4d24391be35c04404aae517c57b6c3d810b625d1 100644 --- a/src/plugins/projectexplorer/toolchain.cpp +++ b/src/plugins/projectexplorer/toolchain.cpp @@ -459,7 +459,40 @@ MSVCToolChain::InstallationList MSVCToolChain::installations() return installs; } -MSVCToolChain::Installation MSVCToolChain::findInstallation(bool is64Bit, +// Return a substring to match the MSVC official version against by mkSpec name. +static inline const QString msvcVersionStringFromMkSpec(const QString &mkSpec) +{ + if (mkSpec.isEmpty()) + return QString(); + if (mkSpec.endsWith(QLatin1String("msvc2002"))) + return QLatin1String(" 7.0"); + if (mkSpec.endsWith(QLatin1String("msvc2003"))) + return QLatin1String(" 7.1"); + if (mkSpec.endsWith(QLatin1String("msvc2005"))) + return QLatin1String(" 8.0"); + if (mkSpec.endsWith(QLatin1String("msvc2008"))) + return QLatin1String(" 9.0"); + if (mkSpec.endsWith(QLatin1String("msvc2010"))) + return QLatin1String(" 10.0"); + return QString(); +} + +MSVCToolChain::Installation MSVCToolChain::findInstallationByMkSpec(bool is64Bit, + const QString &mkSpec, + bool excludeSDK) +{ + const QString mkSpecMatchString = msvcVersionStringFromMkSpec(mkSpec); + if (!mkSpecMatchString.isEmpty()) { + foreach(const Installation &i, installations()) { + if ((i.type == Installation::VS) && (i.is64bit() == is64Bit) + && (i.name.indexOf(mkSpecMatchString) != -1)) + return i; + } + } + return findInstallationByName(is64Bit, QString(), excludeSDK); +} + +MSVCToolChain::Installation MSVCToolChain::findInstallationByName(bool is64Bit, const QString &name, bool excludeSDK) { @@ -488,7 +521,7 @@ PROJECTEXPLORER_EXPORT QDebug operator<<(QDebug in, const MSVCToolChain::Install MSVCToolChain *MSVCToolChain::create(const QString &name, bool amd64) { - return new MSVCToolChain(MSVCToolChain::findInstallation(amd64, name)); + return new MSVCToolChain(MSVCToolChain::findInstallationByName(amd64, name)); } MSVCToolChain::MSVCToolChain(const Installation &in) : @@ -740,7 +773,7 @@ IOutputParser *MSVCToolChain::outputParser() const WinCEToolChain *WinCEToolChain::create(const QString &name, const QString &platform) { const bool excludeSDK = true; - return new WinCEToolChain(findInstallation(false, name, excludeSDK), platform); + return new WinCEToolChain(findInstallationByName(false, name, excludeSDK), platform); } WinCEToolChain::WinCEToolChain(const Installation &in, const QString &platform) : diff --git a/src/plugins/projectexplorer/toolchain.h b/src/plugins/projectexplorer/toolchain.h index ea3453d9e14e89137894bb7139180b9ff74394d4..1fa34b37c11cc6dd2a4f86c879fcf0f82460268c 100644 --- a/src/plugins/projectexplorer/toolchain.h +++ b/src/plugins/projectexplorer/toolchain.h @@ -194,9 +194,12 @@ public: typedef QList<Installation> InstallationList; static InstallationList installations(); // Return matching installation or empty one - static Installation findInstallation(bool is64Bit, - const QString &name = QString(), - bool excludeSDK = false); + static Installation findInstallationByName(bool is64Bit, + const QString &name = QString(), + bool excludeSDK = false); + static Installation findInstallationByMkSpec(bool is64Bit, + const QString &mkSpec, + bool excludeSDK = false); static MSVCToolChain *create(const QString &name, bool amd64 = false); diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index 455c91452c05a2502b5b7c24ea54752a5f59281d..7eef15ae73eef16b81076c3b71795ae0ea6e50ac 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -316,7 +316,7 @@ void QtVersionManager::addNewVersionsFromInstaller() { // Add new versions which may have been installed by the WB installer in the form: // NewQtVersions="qt 4.3.2=c:\\qt\\qt432\bin\qmake.exe;qt embedded=c:\\qtembedded;" - // or NewQtVersions="qt 4.3.2=c:\\qt\\qt432bin\qmake.exe=c:\\qtcreator\\mingw\\; + // or NewQtVersions="qt 4.3.2=c:\\qt\\qt432bin\qmake.exe=c:\\qtcreator\\mingw\\=MSVCName; // i.e. // NewQtVersions="versionname=pathtoversion=mingw=s60sdk=gcce=carbide;" // Duplicate entries are not added, the first new version is set as default. @@ -355,6 +355,8 @@ void QtVersionManager::addNewVersionsFromInstaller() version->setGcceDirectory(QDir::fromNativeSeparators(newVersionData[4])); if (newVersionData.count() >= 6) version->setMwcDirectory(QDir::fromNativeSeparators(newVersionData[5])); + if (newVersionData.count() >= 7) + version->setMsvcVersion(newVersionData[6]); bool versionWasAlreadyInList = false; foreach(const QtVersion * const it, m_versions) { @@ -1367,9 +1369,11 @@ void QtVersion::updateToolChainAndMkspec() const m_toolChains << ToolChainPtr(MaemoManager::instance().maemoToolChain(this)); m_targetIds.insert(QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID)); } else if (qmakeCXX == "cl" || qmakeCXX == "icl") { - // TODO proper support for intel cl + // TODO proper support for intel cl. Detect matching VC version unless set. + if (m_msvcVersion.isEmpty()) + m_msvcVersion = ProjectExplorer::MSVCToolChain::findInstallationByMkSpec(isQt64Bit(), mkspec).name; m_toolChains << ToolChainPtr( - ProjectExplorer::ToolChain::createMSVCToolChain(msvcVersion(), isQt64Bit())); + ProjectExplorer::ToolChain::createMSVCToolChain(m_msvcVersion, isQt64Bit())); m_targetIds.insert(QLatin1String(Constants::DESKTOP_TARGET_ID)); } else if (qmakeCXX == "g++" && makefileGenerator == "MINGW") { ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment(); diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h index e1a191241856b0ea5a96e673af2b6710d0b40fc6..6f5e613bc8ae282bdbce6c1d9d7e3bb92c69a46c 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/qt4projectmanager/qtversionmanager.h @@ -157,7 +157,7 @@ private: QString m_displayName; QString m_sourcePath; QString m_mingwDirectory; - QString m_msvcVersion; + mutable QString m_msvcVersion; int m_id; bool m_isAutodetected; QString m_autodetectionSource;