From 04805e0a9e7e46bd600b618a08dceea5bdce6e29 Mon Sep 17 00:00:00 2001 From: dt Date: Wed, 11 Feb 2009 12:14:51 +0100 Subject: [PATCH] Fixes: Use the toolchain classes int the cmake plugin. Details: We now get the system includes and system defines. --- .../cmakeprojectmanager/cmakeproject.cpp | 54 +++++++++++++++++-- .../cmakeprojectmanager/cmakeproject.h | 4 ++ 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index 34bc8fa7908..6d836388f02 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -67,7 +67,10 @@ using namespace CMakeProjectManager::Internal; CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName) - : m_manager(manager), m_fileName(fileName), m_rootNode(new CMakeProjectNode(m_fileName)) + : m_manager(manager), + m_fileName(fileName), + m_rootNode(new CMakeProjectNode(m_fileName)), + m_toolChain(0) { m_file = new CMakeFile(this, fileName); } @@ -75,12 +78,14 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName) CMakeProject::~CMakeProject() { delete m_rootNode; + delete m_toolChain; } // TODO also call this method if the CMakeLists.txt file changed, which is also called if the CMakeList.txt is updated // TODO make this function work even if it is reparsing void CMakeProject::parseCMakeLists() { + ProjectExplorer::ToolChain *newToolChain = 0; QString sourceDirectory = QFileInfo(m_fileName).absolutePath(); m_manager->createXmlFile(cmakeStep()->userArguments(activeBuildConfiguration()), sourceDirectory, buildDirectory(activeBuildConfiguration())); @@ -88,6 +93,24 @@ void CMakeProject::parseCMakeLists() CMakeCbpParser cbpparser; qDebug()<<"Parsing file "< allHeaderPaths = m_toolChain->systemHeaderPaths(); + foreach (ProjectExplorer::HeaderPath headerPath, allHeaderPaths) { + if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath) + allFrameworkPaths.append(headerPath.path()); + else + allIncludePaths.append(headerPath.path()); + } + allIncludePaths.append(cbpparser.includeFiles()); CppTools::CppModelManagerInterface *modelmanager = ExtensionSystem::PluginManager::instance()->getObject(); if (modelmanager) { CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this); - pinfo.includePaths = cbpparser.includeFiles(); + pinfo.includePaths = allIncludePaths; // TODO we only want C++ files, not all other stuff that might be in the project pinfo.sourceFiles = m_files; - // TODO defines - // TODO gcc preprocessor files + pinfo.defines = m_toolChain->predefinedMacros(); + pinfo.frameworkPaths = allFrameworkPaths; modelmanager->updateProjectInfo(pinfo); } } else { // TODO report error + delete m_toolChain; + m_toolChain = 0; } } @@ -188,6 +224,8 @@ QString CMakeProject::name() const return m_projectName; } + + Core::IFile *CMakeProject::file() const { return m_file; @@ -546,6 +584,9 @@ void CMakeCbpParser::parseOption() if (attributes().hasAttribute("title")) m_projectName = attributes().value("title").toString(); + if (attributes().hasAttribute("compiler")) + m_compiler = attributes().value("compiler").toString(); + while (!atEnd()) { readNext(); if (isEndElement()) { @@ -673,6 +714,11 @@ QList CMakeCbpParser::targets() return m_targets; } +QString CMakeCbpParser::compilerName() const +{ + return m_compiler; +} + void CMakeTarget::clear() { executable = QString::null; diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h index 5195cfb5735..3494441489e 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.h +++ b/src/plugins/cmakeprojectmanager/cmakeproject.h @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -122,6 +123,7 @@ private: CMakeProjectNode* m_rootNode; QStringList m_files; QList m_targets; + ProjectExplorer::ToolChain *m_toolChain; protected: virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer); @@ -137,6 +139,7 @@ public: QStringList includeFiles(); QList targets(); QString projectName() const; + QString compilerName() const; private: void parseCodeBlocks_project_file(); void parseProject(); @@ -159,6 +162,7 @@ private: bool m_targetType; QList m_targets; QString m_projectName; + QString m_compiler; }; class CMakeFile : public Core::IFile