diff --git a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp index c4662e7459677510e761fc671600a90a14a46eaf..1080dc5636a815ae8964f365e6f335a955b6f2e2 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp @@ -408,18 +408,21 @@ void AutotoolsProject::updateCppCodeModel() QStringList allFrameworkPaths; QByteArray macros; + QStringList cxxflags; // FIXME: Autotools should be able to do better than this! + if (activeTarget()) { ProjectExplorer::Kit *k = activeTarget()->kit(); ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k); if (tc) { - const QList<HeaderPath> allHeaderPaths = tc->systemHeaderPaths(SysRootKitInformation::sysRoot(k)); + const QList<HeaderPath> allHeaderPaths = tc->systemHeaderPaths(cxxflags, + SysRootKitInformation::sysRoot(k)); foreach (const HeaderPath &headerPath, allHeaderPaths) { if (headerPath.kind() == HeaderPath::FrameworkHeaderPath) allFrameworkPaths.append(headerPath.path()); else allIncludePaths.append(headerPath.path()); } - macros = tc->predefinedMacros(QStringList()); + macros = tc->predefinedMacros(cxxflags); macros += '\n'; } } diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index b07aab805b741529ff9ab3c07a66e2427a442954..1a6cf70b9da5a61061d3f70dbed721b337c75262 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -303,13 +303,15 @@ bool CMakeProject::parseCMakeLists() allIncludePaths.append(projectDirectory()); allIncludePaths.append(cbpparser.includeFiles()); + QStringList cxxflags; // FIXME: We should do better than this! + QByteArray allDefines; - allDefines.append(tc->predefinedMacros(QStringList())); + allDefines.append(tc->predefinedMacros(cxxflags)); allDefines.append(cbpparser.defines()); QStringList allFrameworkPaths; QList<ProjectExplorer::HeaderPath> allHeaderPaths; - allHeaderPaths = tc->systemHeaderPaths(SysRootKitInformation::sysRoot(k)); + allHeaderPaths = tc->systemHeaderPaths(cxxflags, SysRootKitInformation::sysRoot(k)); foreach (const ProjectExplorer::HeaderPath &headerPath, allHeaderPaths) { if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath) allFrameworkPaths.append(headerPath.path()); diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp index 9a9dc3c6e15c717eb47483f02676be04155b1e2e..16e8e8785f5716a984fc5cec396d9475bb49ee16 100644 --- a/src/plugins/genericprojectmanager/genericproject.cpp +++ b/src/plugins/genericprojectmanager/genericproject.cpp @@ -250,10 +250,11 @@ void GenericProject::refresh(RefreshOptions options) Kit *k = activeTarget() ? activeTarget()->kit() : KitManager::instance()->defaultKit(); ToolChain *tc = k ? ToolChainKitInformation::toolChain(k) : 0; if (tc) { - part->defines = tc->predefinedMacros(QStringList()); + QStringList cxxflags; // FIXME: Can we do better? + part->defines = tc->predefinedMacros(cxxflags); part->defines += '\n'; - foreach (const HeaderPath &headerPath, tc->systemHeaderPaths(SysRootKitInformation::sysRoot(k))) { + foreach (const HeaderPath &headerPath, tc->systemHeaderPaths(cxxflags, SysRootKitInformation::sysRoot(k))) { if (headerPath.kind() == HeaderPath::FrameworkHeaderPath) part->frameworkPaths.append(headerPath.path()); else diff --git a/src/plugins/projectexplorer/abstractmsvctoolchain.cpp b/src/plugins/projectexplorer/abstractmsvctoolchain.cpp index 29d9fb7935a294f39c407c2ea96d87663a5ae823..7e38bae9436770764c5c2dad7a6c0351185424c6 100644 --- a/src/plugins/projectexplorer/abstractmsvctoolchain.cpp +++ b/src/plugins/projectexplorer/abstractmsvctoolchain.cpp @@ -105,8 +105,9 @@ ToolChain::CompilerFlags AbstractMsvcToolChain::compilerFlags(const QStringList } } -QList<HeaderPath> AbstractMsvcToolChain::systemHeaderPaths(const Utils::FileName &sysRoot) const +QList<HeaderPath> AbstractMsvcToolChain::systemHeaderPaths(const QStringList &cxxflags, const Utils::FileName &sysRoot) const { + Q_UNUSED(cxxflags); Q_UNUSED(sysRoot); if (m_headerPaths.isEmpty()) { Utils::Environment env(m_lastEnvironment); diff --git a/src/plugins/projectexplorer/abstractmsvctoolchain.h b/src/plugins/projectexplorer/abstractmsvctoolchain.h index 44ee1b4af15c85567f76403f4e5960da53c535d3..4c364227342cd5b7511baf653b6ec01092872234 100644 --- a/src/plugins/projectexplorer/abstractmsvctoolchain.h +++ b/src/plugins/projectexplorer/abstractmsvctoolchain.h @@ -50,7 +50,7 @@ public: QByteArray predefinedMacros(const QStringList &cxxflags) const; CompilerFlags compilerFlags(const QStringList &cxxflags) const; - QList<HeaderPath> systemHeaderPaths(const Utils::FileName &sysRoot) const; + QList<HeaderPath> systemHeaderPaths(const QStringList &cxxflags, const Utils::FileName &sysRoot) const; void addToEnvironment(Utils::Environment &env) const; QString makeCommand(const Utils::Environment &environment) const; diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index 765720f84b3b067741d1a3263505679b66d7d88e..ceabb4ba172a2110b7791f14d322f5757e1ff954 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -122,7 +122,8 @@ static QByteArray gccPredefinedMacros(const FileName &gcc, const QStringList &ar || a == QLatin1String("-O2") || a == QLatin1String("-O3") || a == QLatin1String("-ffinite-math-only") || a == QLatin1String("-fshort-double") || a == QLatin1String("-fshort-wchar") || a == QLatin1String("-fsignaling-nans") - || a.startsWith(QLatin1String("-std=")) || a.startsWith(QLatin1String("-specs=")) + || a.startsWith(QLatin1String("-std=")) || a.startsWith(QLatin1String("-stdlib=")) + || a.startsWith(QLatin1String("-specs=")) || a == QLatin1String("-ansi") || a.startsWith(QLatin1String("-D")) || a.startsWith(QLatin1String("-U")) || a == QLatin1String("-undef")) @@ -148,12 +149,18 @@ static QByteArray gccPredefinedMacros(const FileName &gcc, const QStringList &ar return predefinedMacros; } -QList<HeaderPath> GccToolChain::gccHeaderPaths(const FileName &gcc, const QStringList &env, const FileName &sysrootPath) +QList<HeaderPath> GccToolChain::gccHeaderPaths(const FileName &gcc, const QStringList &args, + const QStringList &env, const FileName &sysrootPath) { QList<HeaderPath> systemHeaderPaths; QStringList arguments; if (!sysrootPath.isEmpty()) arguments.append(QString::fromLatin1("--sysroot=%1").arg(sysrootPath.toString())); + foreach (const QString &a, args) { + if (a.startsWith(QLatin1String("-stdlib="))) + arguments << a; + } + arguments << QLatin1String("-xc++") << QLatin1String("-E") << QLatin1String("-v") @@ -393,13 +400,13 @@ ToolChain::CompilerFlags GccToolChain::compilerFlags(const QStringList &cxxflags return NO_FLAGS; } -QList<HeaderPath> GccToolChain::systemHeaderPaths(const Utils::FileName &sysRoot) const +QList<HeaderPath> GccToolChain::systemHeaderPaths(const QStringList &cxxflags, const Utils::FileName &sysRoot) const { if (m_headerPaths.isEmpty()) { // Using a clean environment breaks ccache/distcc/etc. Environment env = Environment::systemEnvironment(); addToEnvironment(env); - m_headerPaths = gccHeaderPaths(m_compilerCommand, env.toStringList(), sysRoot); + m_headerPaths = gccHeaderPaths(m_compilerCommand, cxxflags, env.toStringList(), sysRoot); } return m_headerPaths; } diff --git a/src/plugins/projectexplorer/gcctoolchain.h b/src/plugins/projectexplorer/gcctoolchain.h index eca1aa3375b2ec944d33498b59b63b90a3c12d77..273f042ee4b53d86faa495ab6424dce918d47410 100644 --- a/src/plugins/projectexplorer/gcctoolchain.h +++ b/src/plugins/projectexplorer/gcctoolchain.h @@ -63,7 +63,7 @@ public: QByteArray predefinedMacros(const QStringList &cxxflags) const; CompilerFlags compilerFlags(const QStringList &cxxflags) const; - QList<HeaderPath> systemHeaderPaths(const Utils::FileName &sysRoot) const; + QList<HeaderPath> systemHeaderPaths(const QStringList &cxxflags, const Utils::FileName &sysRoot) const; void addToEnvironment(Utils::Environment &env) const; QString makeCommand(const Utils::Environment &environment) const; QList<Utils::FileName> suggestedMkspecList() const; @@ -90,7 +90,7 @@ protected: virtual QList<Abi> detectSupportedAbis() const; virtual QString detectVersion() const; - static QList<HeaderPath> gccHeaderPaths(const Utils::FileName &gcc, const QStringList &env, const Utils::FileName &sysrootPath); + static QList<HeaderPath> gccHeaderPaths(const Utils::FileName &gcc, const QStringList &args, const QStringList &env, const Utils::FileName &sysrootPath); mutable QByteArray m_predefinedMacros; diff --git a/src/plugins/projectexplorer/toolchain.h b/src/plugins/projectexplorer/toolchain.h index 5109baa03329eb5e944d5a0d90b9d6309cfcb4a0..3ea55bbc461f449ed4ea30492dd9468ef3462f93 100644 --- a/src/plugins/projectexplorer/toolchain.h +++ b/src/plugins/projectexplorer/toolchain.h @@ -87,7 +87,8 @@ public: STD_CXX11 = 1 }; virtual CompilerFlags compilerFlags(const QStringList &cxxflags) const = 0; - virtual QList<HeaderPath> systemHeaderPaths(const Utils::FileName &sysRoot) const = 0; + virtual QList<HeaderPath> systemHeaderPaths(const QStringList &cxxflags, + const Utils::FileName &sysRoot) const = 0; virtual void addToEnvironment(Utils::Environment &env) const = 0; virtual QString makeCommand(const Utils::Environment &env) const = 0; diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index 267826dff471b4388a9d985814917c1033ed3439..10e5af5186a98426fb7da0bfa9683b406bbfb12e 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -541,9 +541,11 @@ void Qt4Project::updateCppCodeModel() ProjectPart::Ptr part(new ProjectPart); part->qtVersion = qtVersionForPart; + QStringList cxxflags = pro->variableValue(CppFlagsVar); + // part->defines if (tc) - part->defines = tc->predefinedMacros(pro->variableValue(CppFlagsVar)); + part->defines = tc->predefinedMacros(cxxflags); part->defines += pro->cxxDefines(); // part->includePaths @@ -551,7 +553,7 @@ void Qt4Project::updateCppCodeModel() QList<HeaderPath> headers; if (tc) - headers = tc->systemHeaderPaths(SysRootKitInformation::sysRoot(k)); // todo pass cxxflags? + headers = tc->systemHeaderPaths(cxxflags, SysRootKitInformation::sysRoot(k)); if (qtVersion) { headers.append(qtVersion->systemHeaderPathes(k)); }