diff --git a/src/plugins/projectexplorer/abi.cpp b/src/plugins/projectexplorer/abi.cpp index 54bb5577749..7c5295fac51 100644 --- a/src/plugins/projectexplorer/abi.cpp +++ b/src/plugins/projectexplorer/abi.cpp @@ -789,6 +789,28 @@ QList Abi::flavorsForOs(const Abi::OS &o) return result; } +Abi::OSFlavor Abi::flavorForMsvcVersion(int version) +{ + if (version >= 1910) + return WindowsMsvc2017Flavor; + switch (version) { + case 1900: + return WindowsMsvc2015Flavor; + case 1800: + return WindowsMsvc2013Flavor; + case 1700: + return WindowsMsvc2012Flavor; + case 1600: + return WindowsMsvc2010Flavor; + case 1500: + return WindowsMsvc2008Flavor; + case 1400: + return WindowsMsvc2005Flavor; + default: + return WindowsMSysFlavor; + } +} + Abi Abi::hostAbi() { Architecture arch = QTC_CPU; // define set by qmake @@ -798,20 +820,8 @@ Abi Abi::hostAbi() #if defined (Q_OS_WIN) os = WindowsOS; -#if _MSC_VER >= 1910 - subos = WindowsMsvc2017Flavor; -#elif _MSC_VER == 1900 - subos = WindowsMsvc2015Flavor; -#elif _MSC_VER == 1800 - subos = WindowsMsvc2013Flavor; -#elif _MSC_VER == 1700 - subos = WindowsMsvc2012Flavor; -#elif _MSC_VER == 1600 - subos = WindowsMsvc2010Flavor; -#elif _MSC_VER == 1500 - subos = WindowsMsvc2008Flavor; -#elif _MSC_VER == 1400 - subos = WindowsMsvc2005Flavor; +#ifdef _MSC_VER + subos = flavorForMsvcVersion(_MSC_VER); #elif defined (Q_CC_MINGW) subos = WindowsMSysFlavor; #endif diff --git a/src/plugins/projectexplorer/abi.h b/src/plugins/projectexplorer/abi.h index 77e769131e6..06157aa81b0 100644 --- a/src/plugins/projectexplorer/abi.h +++ b/src/plugins/projectexplorer/abi.h @@ -139,6 +139,7 @@ public: static QString toString(int w); static QList flavorsForOs(const OS &o); + static OSFlavor flavorForMsvcVersion(int version); static Abi hostAbi(); static QList abisOfBinary(const Utils::FileName &path); diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index ae4c9813d8e..8bb25b5a6db 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -269,11 +269,19 @@ static QList guessGccAbi(const QString &m, const QByteArray ¯os) Abi::OSFlavor flavor = guessed.osFlavor(); Abi::BinaryFormat format = guessed.binaryFormat(); int width = guessed.wordWidth(); + const QByteArray mscVer = "#define _MSC_VER "; if (macros.contains("#define __SIZEOF_SIZE_T__ 8")) width = 64; else if (macros.contains("#define __SIZEOF_SIZE_T__ 4")) width = 32; + int mscVerIndex = macros.indexOf(mscVer); + if (mscVerIndex != -1) { + mscVerIndex += mscVer.length(); + const int eol = macros.indexOf('\n', mscVerIndex); + const int msvcVersion = macros.mid(mscVerIndex, eol - mscVerIndex).toInt(); + flavor = Abi::flavorForMsvcVersion(msvcVersion); + } if (os == Abi::DarwinOS) { // Apple does PPC and x86!