diff options
Diffstat (limited to 'src/plugins/cpptools/cppmodelmanagerinterface.cpp')
-rw-r--r-- | src/plugins/cpptools/cppmodelmanagerinterface.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.cpp b/src/plugins/cpptools/cppmodelmanagerinterface.cpp index da9cc55605..909ed4c253 100644 --- a/src/plugins/cpptools/cppmodelmanagerinterface.cpp +++ b/src/plugins/cpptools/cppmodelmanagerinterface.cpp @@ -29,6 +29,8 @@ #include "cppmodelmanagerinterface.h" +#include <projectexplorer/toolchain.h> +#include <projectexplorer/headerpath.h> #include <cplusplus/pp-engine.h> #include <QtCore/QSet> @@ -48,6 +50,61 @@ */ using namespace CppTools; +using namespace ProjectExplorer; + +/** + * @brief Retrieves info from concrete compiler using it's flags. + * @param tc Either nullptr or toolchain for project's active target. + * @param cxxflags C++ or Objective-C++ flags. + * @param cflags C or ObjectiveC flags if possible, \a cxxflags otherwise. + */ +void ProjectPart::evaluateToolchain(const ToolChain *tc, + const QStringList &cxxflags, + const QStringList &cflags, + const Utils::FileName &sysRoot) +{ + if (!tc) + return; + ToolChain::CompilerFlags cxx = tc->compilerFlags(cxxflags); + ToolChain::CompilerFlags c = (cxxflags == cflags) + ? cxx : tc->compilerFlags(cflags); + + if (c | ToolChain::StandardC11) + cVersion = C11; + else if (c | ToolChain::StandardC99) + cVersion = C99; + else + cVersion = C89; + + if (cxx | ToolChain::StandardCxx11) + cxxVersion = CXX11; + else + cxxVersion = CXX98; + + if (cxx | ToolChain::BorlandExtensions) + cxxExtensions |= BorlandExtensions; + if (cxx | ToolChain::GnuExtensions) + cxxExtensions |= GnuExtensions; + if (cxx | ToolChain::MicrosoftExtensions) + cxxExtensions |= MicrosoftExtensions; + if (cxx | ToolChain::OpenMP) + cxxExtensions |= OpenMP; + + QList<HeaderPath> headers = tc->systemHeaderPaths(cxxflags, sysRoot); + foreach (const HeaderPath &header, headers) + if (header.kind() == HeaderPath::FrameworkHeaderPath) + frameworkPaths << header.path(); + else + includePaths << header.path(); + + QByteArray macros = tc->predefinedMacros(cxxflags); + if (!macros.isEmpty()) { + if (!defines.isEmpty()) + defines += '\n'; + defines += macros; + defines += '\n'; + } +} static CppModelManagerInterface *g_instance = 0; |