From 2d8a9674b42dea871efaa1bca5b96cbaeec4b060 Mon Sep 17 00:00:00 2001 From: Sergey Shambir Date: Sun, 28 Apr 2013 16:23:01 +0400 Subject: [PATCH] CMake: simplified C++ codemodel interaction. Now it uses ProjectPart::evaluateToolchain() to read toolchain info with given compiler flags, so it saves old behavior and also reads C version and C++ extensions. Removed check that model doesn't need to be updated, since check didn't account ProjectPart enums. Change-Id: I6dbebeecdb162ec5b885f9f1846756b586c22b23 Reviewed-by: Daniel Teske --- .../cmakeprojectmanager/cmakeproject.cpp | 68 +++++++------------ 1 file changed, 24 insertions(+), 44 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index 438c9c9bb50..87efca9c1c5 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -314,11 +314,6 @@ bool CMakeProject::parseCMakeLists() return true; } - QStringList allIncludePaths; - // This explicitly adds -I. to the include paths - allIncludePaths.append(projectDirectory()); - allIncludePaths.append(cbpparser.includeFiles()); - QStringList cxxflags; bool found = false; foreach (const CMakeBuildTarget &buildTarget, m_buildTargets) { @@ -374,51 +369,36 @@ bool CMakeProject::parseCMakeLists() } } - QByteArray allDefines; - allDefines.append(tc->predefinedMacros(cxxflags)); - allDefines.append(cbpparser.defines()); - - QStringList allFrameworkPaths; - QList allHeaderPaths; - allHeaderPaths = tc->systemHeaderPaths(cxxflags, SysRootKitInformation::sysRoot(k)); - foreach (const ProjectExplorer::HeaderPath &headerPath, allHeaderPaths) { - if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath) - allFrameworkPaths.append(headerPath.path()); - else - allIncludePaths.append(headerPath.path()); - } - CppTools::CppModelManagerInterface *modelmanager = CppTools::CppModelManagerInterface::instance(); if (modelmanager) { CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this); - if (pinfo.includePaths() != allIncludePaths - || pinfo.sourceFiles() != m_files - || pinfo.defines() != allDefines - || pinfo.frameworkPaths() != allFrameworkPaths) { - pinfo.clearProjectParts(); - CppTools::ProjectPart::Ptr part(new CppTools::ProjectPart); - part->includePaths = allIncludePaths; - CppTools::ProjectFileAdder adder(part->files); - foreach (const QString &file, m_files) - adder.maybeAdd(file); - part->defines = allDefines; - part->frameworkPaths = allFrameworkPaths; - part->cVersion = CppTools::ProjectPart::C99; - if (tc) - part->cxxVersion = (tc->compilerFlags(cxxflags) | ToolChain::StandardCxx11) - ? CppTools::ProjectPart::CXX11 - : CppTools::ProjectPart::CXX98; - else - part->cxxVersion = CppTools::ProjectPart::CXX11; - pinfo.appendProjectPart(part); - modelmanager->updateProjectInfo(pinfo); - m_codeModelFuture.cancel(); - m_codeModelFuture = modelmanager->updateSourceFiles(m_files); + pinfo.clearProjectParts(); - setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !part->files.isEmpty()); - } + CppTools::ProjectPart::Ptr part(new CppTools::ProjectPart); + + part->evaluateToolchain(tc, + cxxflags, + cxxflags, + SysRootKitInformation::sysRoot(k)); + + // This explicitly adds -I. to the include paths + part->includePaths += projectDirectory(); + part->includePaths += cbpparser.includeFiles(); + part->defines += cbpparser.defines(); + + CppTools::ProjectFileAdder adder(part->files); + foreach (const QString &file, m_files) + adder.maybeAdd(file); + + pinfo.appendProjectPart(part); + modelmanager->updateProjectInfo(pinfo); + m_codeModelFuture.cancel(); + m_codeModelFuture = modelmanager->updateSourceFiles(m_files); + + setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !part->files.isEmpty()); } + emit buildTargetsChanged(); emit fileListChanged();