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