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();