Commit cd3238ce authored by Benjamin Zeller's avatar Benjamin Zeller

CMakeProjectManager: Export CMakeProject

Export CMakeProject to make it possible for plugins
to inspect the BuildTargets of a cmake project.

Change-Id: Ia7eb94689afefee7789e32ec009579856746787a
Reviewed-by: default avatarDaniel Teske <daniel.teske@theqtcompany.com>
parent 7ca9f1f2
......@@ -35,6 +35,8 @@
#include "cmakeproject.h"
#include "cmakeprojectconstants.h"
#include "cmakebuildsettingswidget.h"
#include "cmakeprojectmanager.h"
#include "makestep.h"
#include <coreplugin/documentmanager.h>
#include <coreplugin/icore.h>
......@@ -190,13 +192,14 @@ ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(Proj
CMakeBuildInfo copy(*static_cast<const CMakeBuildInfo *>(info));
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
CMakeManager *manager = static_cast<CMakeManager *>(project->projectManager());
if (copy.buildDirectory.isEmpty()) {
copy.buildDirectory = shadowBuildDirectory(project->projectFilePath(), parent->kit(),
copy.displayName);
}
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), project->projectManager(), CMakeOpenProjectWizard::ChangeDirectory, &copy);
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), manager, CMakeOpenProjectWizard::ChangeDirectory, &copy);
if (copw.exec() != QDialog::Accepted)
return 0;
......
......@@ -38,9 +38,9 @@ namespace ProjectExplorer { class ToolChain; }
namespace CMakeProjectManager {
class CMakeBuildInfo;
class CMakeProject;
namespace Internal {
class CMakeProject;
class CMakeBuildConfigurationFactory;
......@@ -75,7 +75,7 @@ private:
QString m_msvcVersion;
bool m_useNinja;
friend class CMakeProject;
friend class CMakeProjectManager::CMakeProject;
};
class CMakeBuildConfigurationFactory : public ProjectExplorer::IBuildConfigurationFactory
......
......@@ -82,9 +82,10 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog()
{
CMakeProject *project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project());
CMakeManager *manager = static_cast<CMakeManager *>(project->projectManager());
CMakeBuildInfo info(m_buildConfiguration);
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(),
project->projectManager(), CMakeOpenProjectWizard::ChangeDirectory,
manager, CMakeOpenProjectWizard::ChangeDirectory,
&info);
if (copw.exec() == QDialog::Accepted) {
project->changeBuildDirectory(m_buildConfiguration, copw.buildDirectory());
......@@ -98,9 +99,10 @@ void CMakeBuildSettingsWidget::runCMake()
if (!ProjectExplorer::ProjectExplorerPlugin::saveModifiedFiles())
return;
CMakeProject *project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project());
CMakeManager *manager = static_cast<CMakeManager *>(project->projectManager());
CMakeBuildInfo info(m_buildConfiguration);
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(),
project->projectManager(),
manager,
CMakeOpenProjectWizard::WantToUpdate, &info);
if (copw.exec() == QDialog::Accepted)
project->parseCMakeLists();
......
......@@ -34,9 +34,9 @@
#include <coreplugin/idocument.h>
namespace CMakeProjectManager {
class CMakeProject;
namespace Internal {
class CMakeProject;
class CMakeFile : public Core::IDocument
{
......
......@@ -468,7 +468,7 @@ Core::IDocument *CMakeProject::document() const
return m_file;
}
CMakeManager *CMakeProject::projectManager() const
IProjectManager *CMakeProject::projectManager() const
{
return m_manager;
}
......
......@@ -31,10 +31,8 @@
#ifndef CMAKEPROJECT_H
#define CMAKEPROJECT_H
#include "cmakeprojectmanager.h"
#include "cmake_global.h"
#include "cmakeprojectnodes.h"
#include "cmakebuildconfiguration.h"
#include "makestep.h"
#include <projectexplorer/project.h>
#include <projectexplorer/buildconfiguration.h>
......@@ -59,6 +57,10 @@ namespace CMakeProjectManager {
namespace Internal {
class CMakeFile;
class CMakeBuildSettingsWidget;
class CMakeBuildConfiguration;
class CMakeProjectNode;
class CMakeManager;
}
enum TargetType {
ExecutableType = 0,
......@@ -66,7 +68,7 @@ enum TargetType {
DynamicLibraryType = 3
};
struct CMakeBuildTarget
struct CMAKE_EXPORT CMakeBuildTarget
{
QString title;
QString executable; // TODO: rename to output?
......@@ -85,18 +87,18 @@ struct CMakeBuildTarget
void clear();
};
class CMakeProject : public ProjectExplorer::Project
class CMAKE_EXPORT CMakeProject : public ProjectExplorer::Project
{
Q_OBJECT
// for changeBuildDirectory
friend class CMakeBuildSettingsWidget;
friend class Internal::CMakeBuildSettingsWidget;
public:
CMakeProject(CMakeManager *manager, const Utils::FileName &filename);
CMakeProject(Internal::CMakeManager *manager, const Utils::FileName &filename);
~CMakeProject();
QString displayName() const;
Core::IDocument *document() const;
CMakeManager *projectManager() const;
ProjectExplorer::IProjectManager *projectManager() const;
ProjectExplorer::ProjectNode *rootProjectNode() const;
......@@ -120,7 +122,7 @@ protected:
bool setupTarget(ProjectExplorer::Target *t);
// called by CMakeBuildSettingsWidget
void changeBuildDirectory(CMakeBuildConfiguration *bc, const QString &newBuildDirectory);
void changeBuildDirectory(Internal::CMakeBuildConfiguration *bc, const QString &newBuildDirectory);
private slots:
void fileChanged(const QString &fileName);
......@@ -130,23 +132,23 @@ private slots:
void updateRunConfigurations();
private:
void buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
void buildTree(Internal::CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list);
ProjectExplorer::FolderNode *findOrCreateFolder(CMakeProjectNode *rootNode, QString directory);
ProjectExplorer::FolderNode *findOrCreateFolder(Internal::CMakeProjectNode *rootNode, QString directory);
void createUiCodeModelSupport();
QString uiHeaderFile(const QString &uiFile);
void updateRunConfigurations(ProjectExplorer::Target *t);
void updateApplicationAndDeploymentTargets();
QStringList getCXXFlagsFor(const CMakeBuildTarget &buildTarget);
CMakeManager *m_manager;
Internal::CMakeManager *m_manager;
ProjectExplorer::Target *m_activeTarget;
Utils::FileName m_fileName;
CMakeFile *m_file;
Internal::CMakeFile *m_file;
QString m_projectName;
// TODO probably need a CMake specific node structure
CMakeProjectNode *m_rootNode;
Internal::CMakeProjectNode *m_rootNode;
QStringList m_files;
QList<CMakeBuildTarget> m_buildTargets;
QFileSystemWatcher *m_watcher;
......@@ -154,7 +156,6 @@ private:
QFuture<void> m_codeModelFuture;
};
} // namespace Internal
} // namespace CMakeProjectManager
#endif // CMAKEPROJECT_H
......@@ -34,6 +34,8 @@
#include <projectexplorer/projectnodes.h>
namespace CMakeProjectManager {
class CMakeProject;
namespace Internal {
class CMakeProjectNode : public ProjectExplorer::ProjectNode
......
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