Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -175,9 +175,15 @@ void CMakeProject::parseCMakeLists() ...@@ -175,9 +175,15 @@ void CMakeProject::parseCMakeLists()
//qDebug()<<"Building Tree"; //qDebug()<<"Building Tree";
QList<ProjectExplorer::FileNode *> fileList = cbpparser.fileList(); 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(); m_files.clear();
foreach (ProjectExplorer::FileNode *fn, fileList) foreach (ProjectExplorer::FileNode *fn, fileList)
...@@ -941,18 +947,43 @@ void CMakeCbpParser::parseUnit() ...@@ -941,18 +947,43 @@ void CMakeCbpParser::parseUnit()
{ {
//qDebug()<<stream.attributes().value("filename"); //qDebug()<<stream.attributes().value("filename");
QString fileName = attributes().value("filename").toString(); QString fileName = attributes().value("filename").toString();
if (!fileName.endsWith(".rule")) m_parsingCmakeUnit = false;
m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::SourceType, false));
while (!atEnd()) { while (!atEnd()) {
readNext(); readNext();
if (isEndElement()) { 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; return;
} else if (name() == "Option") {
parseUnitOption();
} else if (isStartElement()) { } else if (isStartElement()) {
parseUnknownElement(); parseUnknownElement();
} }
} }
} }
void CMakeCbpParser::parseUnitOption()
{
if (attributes().hasAttribute("virtualFolder"))
m_parsingCmakeUnit = true;
while (!atEnd()) {
readNext();
if (isEndElement())
break;
if (isStartElement())
parseUnknownElement();
}
}
void CMakeCbpParser::parseUnknownElement() void CMakeCbpParser::parseUnknownElement()
{ {
Q_ASSERT(isStartElement()); Q_ASSERT(isStartElement());
...@@ -973,6 +1004,16 @@ QList<ProjectExplorer::FileNode *> CMakeCbpParser::fileList() ...@@ -973,6 +1004,16 @@ QList<ProjectExplorer::FileNode *> CMakeCbpParser::fileList()
return m_fileList; return m_fileList;
} }
QList<ProjectExplorer::FileNode *> CMakeCbpParser::cmakeFileList()
{
return m_cmakeFileList;
}
bool CMakeCbpParser::hasCMakeFiles()
{
return !m_cmakeFileList.isEmpty();
}
QStringList CMakeCbpParser::includeFiles() QStringList CMakeCbpParser::includeFiles()
{ {
return m_includeFiles; return m_includeFiles;
......
...@@ -145,10 +145,12 @@ class CMakeCbpParser : public QXmlStreamReader ...@@ -145,10 +145,12 @@ class CMakeCbpParser : public QXmlStreamReader
public: public:
bool parseCbpFile(const QString &fileName); bool parseCbpFile(const QString &fileName);
QList<ProjectExplorer::FileNode *> fileList(); QList<ProjectExplorer::FileNode *> fileList();
QList<ProjectExplorer::FileNode *> cmakeFileList();
QStringList includeFiles(); QStringList includeFiles();
QList<CMakeTarget> targets(); QList<CMakeTarget> targets();
QString projectName() const; QString projectName() const;
QString compilerName() const; QString compilerName() const;
bool hasCMakeFiles();
private: private:
void parseCodeBlocks_project_file(); void parseCodeBlocks_project_file();
void parseProject(); void parseProject();
...@@ -162,9 +164,13 @@ private: ...@@ -162,9 +164,13 @@ private:
void parseCompiler(); void parseCompiler();
void parseAdd(); void parseAdd();
void parseUnit(); void parseUnit();
void parseUnitOption();
void parseUnknownElement(); void parseUnknownElement();
QList<ProjectExplorer::FileNode *> m_fileList; QList<ProjectExplorer::FileNode *> m_fileList;
QList<ProjectExplorer::FileNode *> m_cmakeFileList;
QSet<QString> m_processedUnits;
bool m_parsingCmakeUnit;
QStringList m_includeFiles; QStringList m_includeFiles;
CMakeTarget m_target; CMakeTarget m_target;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment