Commit 7debdc2b authored by dt's avatar dt
Browse files

Add all cmake files to the project tree

That is if using a cmake that outputs enough information. The necessary
patch for that was commited to cmake's cvs recently by Alexander
Neundorf.

Task-Nr: 250399
parent bc3fde7f
......@@ -175,9 +175,15 @@ void CMakeProject::parseCMakeLists()
//qDebug()<<"Building Tree";
QList<ProjectExplorer::FileNode *> fileList = cbpparser.fileList();
// Manually add the CMakeLists.txt file
fileList.append(new ProjectExplorer::FileNode(sourceDirectory() + "/CMakeLists.txt", ProjectExplorer::ProjectFileType, false));
if (cbpparser.hasCMakeFiles()) {
fileList.append(cbpparser.cmakeFileList());
} else {
// Manually add the CMakeLists.txt file
fileList.append(new ProjectExplorer::FileNode(sourceDirectory() + "/CMakeLists.txt", ProjectExplorer::ProjectFileType, false));
}
m_files.clear();
foreach (ProjectExplorer::FileNode *fn, fileList)
......@@ -941,18 +947,43 @@ void CMakeCbpParser::parseUnit()
{
//qDebug()<<stream.attributes().value("filename");
QString fileName = attributes().value("filename").toString();
if (!fileName.endsWith(".rule"))
m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::SourceType, false));
m_parsingCmakeUnit = false;
while (!atEnd()) {
readNext();
if (isEndElement()) {
if (!fileName.endsWith(".rule") && !m_processedUnits.contains(fileName)) {
// Now check whether we found a virtual element beneath
if (m_parsingCmakeUnit)
m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::SourceType, false));
else
m_cmakeFileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::ProjectFileType, false));
m_processedUnits.insert(fileName);
}
return;
} else if (name() == "Option") {
parseUnitOption();
} else if (isStartElement()) {
parseUnknownElement();
}
}
}
void CMakeCbpParser::parseUnitOption()
{
if (attributes().hasAttribute("virtualFolder"))
m_parsingCmakeUnit = true;
while (!atEnd()) {
readNext();
if (isEndElement())
break;
if (isStartElement())
parseUnknownElement();
}
}
void CMakeCbpParser::parseUnknownElement()
{
Q_ASSERT(isStartElement());
......@@ -973,6 +1004,16 @@ QList<ProjectExplorer::FileNode *> CMakeCbpParser::fileList()
return m_fileList;
}
QList<ProjectExplorer::FileNode *> CMakeCbpParser::cmakeFileList()
{
return m_cmakeFileList;
}
bool CMakeCbpParser::hasCMakeFiles()
{
return !m_cmakeFileList.isEmpty();
}
QStringList CMakeCbpParser::includeFiles()
{
return m_includeFiles;
......
......@@ -145,10 +145,12 @@ class CMakeCbpParser : public QXmlStreamReader
public:
bool parseCbpFile(const QString &fileName);
QList<ProjectExplorer::FileNode *> fileList();
QList<ProjectExplorer::FileNode *> cmakeFileList();
QStringList includeFiles();
QList<CMakeTarget> targets();
QString projectName() const;
QString compilerName() const;
bool hasCMakeFiles();
private:
void parseCodeBlocks_project_file();
void parseProject();
......@@ -162,9 +164,13 @@ private:
void parseCompiler();
void parseAdd();
void parseUnit();
void parseUnitOption();
void parseUnknownElement();
QList<ProjectExplorer::FileNode *> m_fileList;
QList<ProjectExplorer::FileNode *> m_cmakeFileList;
QSet<QString> m_processedUnits;
bool m_parsingCmakeUnit;
QStringList m_includeFiles;
CMakeTarget m_target;
......
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