~iahmad/kubuntu-packaging/qtcreator

« back to all changes in this revision

Viewing changes to src/shared/qbs/src/app/detect-toolchains/msvcprobe.cpp

  • Committer: Timo Jyrinki
  • Date: 2014-01-15 07:44:24 UTC
  • mfrom: (1.1.30)
  • Revision ID: timo.jyrinki@canonical.com-20140115074424-3pnj3a1x6s25im9v
ImportĀ upstreamĀ versionĀ 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
Q_DECLARE_TYPEINFO(MSVC, Q_MOVABLE_TYPE);
65
65
QT_END_NAMESPACE
66
66
 
67
 
static void addMSVCPlatform(Settings *settings, QList<Profile> &profiles, QString name,
68
 
        const QString &installPath, const QString &winSDKPath, const QString &architecture)
 
67
static void addMSVCPlatform(const MSVC &msvc, Settings *settings, QList<Profile> &profiles,
 
68
        QString name, const QString &installPath, const QString &winSDKPath,
 
69
        const QString &architecture)
69
70
{
70
71
    name.append(QLatin1Char('_') + architecture);
71
72
    qbsInfo() << Tr::tr("Setting up profile '%1'.").arg(name);
76
77
    p.setValue("qbs.toolchain", QStringList("msvc"));
77
78
    p.setValue("cpp.windowsSDKPath", winSDKPath);
78
79
    p.setValue("qbs.architecture", canonicalizeArchitecture(architecture));
 
80
    if (msvc.version.toInt() >= 2013) {
 
81
        const QStringList flags(QLatin1String("/FS"));
 
82
        p.setValue("cpp.platformCFlags", flags);
 
83
        p.setValue("cpp.platformCxxFlags", flags);
 
84
    }
79
85
    profiles << p;
80
86
}
81
87
 
87
93
        msvc->architectures += QLatin1String("x86_64");
88
94
}
89
95
 
 
96
static QString wow6432Key()
 
97
{
 
98
#ifdef Q_OS_WIN64
 
99
    return QLatin1String("\\Wow6432Node");
 
100
#else
 
101
    return QString();
 
102
#endif
 
103
}
 
104
 
90
105
void msvcProbe(Settings *settings, QList<Profile> &profiles)
91
106
{
92
107
    qbsInfo() << Tr::tr("Detecting MSVC toolchains...");
94
109
    // 1) Installed SDKs preferred over standalone Visual studio
95
110
    QVector<WinSDK> winSDKs;
96
111
    WinSDK defaultWinSDK;
97
 
    const QSettings sdkRegistry(QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows"),
 
112
 
 
113
    const QSettings sdkRegistry(QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE") + wow6432Key()
 
114
                                + QLatin1String("\\Microsoft\\Microsoft SDKs\\Windows"),
98
115
                                QSettings::NativeFormat);
99
116
    const QString defaultSdkPath = sdkRegistry.value(QLatin1String("CurrentInstallFolder")).toString();
100
117
    if (!defaultSdkPath.isEmpty()) {
101
118
        foreach (const QString &sdkKey, sdkRegistry.childGroups()) {
102
119
            WinSDK sdk;
103
 
            sdk.version = sdkRegistry.value(sdkKey + QLatin1String("/ProductVersion")).toString();
 
120
            sdk.version = sdkKey;
104
121
            sdk.installPath = sdkRegistry.value(sdkKey + QLatin1String("/InstallationFolder")).toString();
105
122
            sdk.isDefault = (sdk.installPath == defaultSdkPath);
106
123
            if (sdk.installPath.isEmpty())
115
132
    }
116
133
 
117
134
    foreach (const WinSDK &sdk, winSDKs) {
118
 
        qbsInfo() << Tr::tr("  Windows SDK detected:\n"
119
 
                            "    version %1\n"
 
135
        qbsInfo() << Tr::tr("  Windows SDK %1 detected:\n"
120
136
                            "    installed in %2").arg(sdk.version, sdk.installPath);
121
137
        if (!sdk.architectures.isEmpty())
122
138
            qbsInfo() << Tr::tr("    This SDK contains C++ compiler(s).");
127
143
    // 2) Installed MSVCs
128
144
    QVector<MSVC> msvcs;
129
145
    const QSettings vsRegistry(
130
 
#ifdef Q_OS_WIN64
131
 
                QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7"),
132
 
#else
133
 
                QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7"),
134
 
#endif
 
146
                QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE") + wow6432Key()
 
147
                + QLatin1String("\\Microsoft\\VisualStudio\\SxS\\VC7"),
135
148
                QSettings::NativeFormat);
136
149
    foreach (const QString &vsName, vsRegistry.allKeys()) {
137
150
        // Scan for version major.minor
192
205
 
193
206
    foreach (const WinSDK &sdk, winSDKs) {
194
207
        foreach (const QString &arch, sdk.architectures) {
195
 
            addMSVCPlatform(settings, profiles, QLatin1String("WinSDK") + sdk.version,
 
208
            addMSVCPlatform(sdk, settings, profiles, QLatin1String("WinSDK") + sdk.version,
196
209
                    sdk.installPath + QLatin1String("\\bin"), defaultWinSDK.installPath, arch);
197
210
        }
198
211
    }
199
212
 
200
213
    foreach (const MSVC &msvc, msvcs) {
201
214
        foreach (const QString &arch, msvc.architectures) {
202
 
            addMSVCPlatform(settings, profiles, QLatin1String("MSVC") + msvc.version,
 
215
            addMSVCPlatform(msvc, settings, profiles, QLatin1String("MSVC") + msvc.version,
203
216
                    msvc.installPath, defaultWinSDK.installPath, arch);
204
217
        }
205
218
    }