Commit 2d8a9674 authored by Sergey Shambir's avatar Sergey Shambir
Browse files

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: default avatarDaniel Teske <daniel.teske@digia.com>
parent 00885ca9
......@@ -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<ProjectExplorer::HeaderPath> 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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment