diff --git a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp index ea9f4245385d9059ecdc092d48126d070c9b1120..f60d20cb2625669d44c4a4020aa1cb5b02b9dd4d 100644 --- a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp @@ -105,10 +105,15 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const m_creatingCbpFiles(true), m_environment(env) { + + CMakeRunPage::Mode rmode; if (mode == CMakeOpenProjectWizard::NeedToCreate) - addPage(new CMakeRunPage(this, CMakeRunPage::Recreate, buildDirectory)); + rmode = CMakeRunPage::Recreate; + else if (mode == CMakeOpenProjectWizard::WantToUpdate) + rmode = CMakeRunPage::WantToUpdate; else - addPage(new CMakeRunPage(this, CMakeRunPage::Update, buildDirectory)); + rmode = CMakeRunPage::NeedToUpdate; + addPage(new CMakeRunPage(this, rmode, buildDirectory)); init(); } @@ -122,7 +127,7 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const { m_buildDirectory = oldBuildDirectory; addPage(new ShadowBuildPage(this, true)); - addPage(new CMakeRunPage(this, CMakeRunPage::Change)); + addPage(new CMakeRunPage(this, CMakeRunPage::ChangeDirectory)); init(); } @@ -342,7 +347,7 @@ void CMakeRunPage::initializePage() tr("The directory %1 does not contain a cbp file. Qt Creator needs to create this file by running cmake. " "Some projects require command line arguments to the initial cmake call.").arg(m_buildDirectory)); } - } else if (m_mode == CMakeRunPage::Update) { + } else if (m_mode == CMakeRunPage::NeedToUpdate) { m_descriptionLabel->setText(tr("The directory %1 contains an outdated .cbp file. Qt " "Creator needs to update this file by running cmake. " "If you want to add additional command line arguments, " @@ -355,11 +360,13 @@ void CMakeRunPage::initializePage() "Some projects require command line arguments to " "the initial cmake call. Note that cmake remembers command " "line arguments from the previous runs.").arg(m_buildDirectory)); - } else if(m_mode == CMakeRunPage::Change) { + } else if(m_mode == CMakeRunPage::ChangeDirectory) { m_buildDirectory = m_cmakeWizard->buildDirectory(); m_descriptionLabel->setText(tr("Qt Creator needs to run cmake in the new build directory. " "Some projects require command line arguments to the " "initial cmake call.")); + } else if (m_mode == CMakeRunPage::WantToUpdate) { + m_descriptionLabel->setText(tr("Refreshing cbp file in %1.").arg(m_buildDirectory)); } if (m_cmakeWizard->cmakeManager()->hasCodeBlocksMsvcGenerator()) { m_generatorComboBox->setVisible(true); diff --git a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h index 573cc5026890908ab4ca2391931287967576b6b8..14d020d531ecfba3c372aa00ccedffce2a83ab99 100644 --- a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h +++ b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h @@ -62,14 +62,18 @@ public: enum Mode { Nothing, NeedToCreate, - NeedToUpdate + NeedToUpdate, + WantToUpdate }; // used at importing a project without a .user file CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const ProjectExplorer::Environment &env); - // used to update if we have already a .user file + /// used to update if we have already a .user file + /// recreates or updates the cbp file CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const QString &buildDirectory, Mode mode, const ProjectExplorer::Environment &env); - // used to change the build directory of one buildconfiguration + /// used to change the build directory of one buildconfiguration + /// shows a page for selecting a directory + /// then the run cmake page CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, const QString &oldBuildDirectory, const ProjectExplorer::Environment &env); virtual int nextId() const; @@ -120,7 +124,7 @@ class CMakeRunPage : public QWizardPage { Q_OBJECT public: - enum Mode { Initial, Update, Recreate, Change }; + enum Mode { Initial, NeedToUpdate, Recreate, ChangeDirectory, WantToUpdate }; explicit CMakeRunPage(CMakeOpenProjectWizard *cmakeWizard, Mode mode = Initial, const QString &buildDirectory = QString()); virtual void initializePage(); diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index 924454fbfa7eafd946c00b211e3fd6ad21dbc57b..bee7b10d37ecc1231267c42752556126c8e0b414 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -623,6 +623,13 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeProject *project) fl->setContentsMargins(20, -1, 0, -1); fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); setLayout(fl); + + // TODO add action to Build menu? + QPushButton *runCmakeButton = new QPushButton("Run cmake"); + connect(runCmakeButton, SIGNAL(clicked()), + this, SLOT(runCMake())); + fl->addRow(tr("Reconfigure project:"), runCmakeButton); + m_pathLineEdit = new QLineEdit(this); m_pathLineEdit->setReadOnly(true); @@ -664,6 +671,19 @@ void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog() } } +void CMakeBuildSettingsWidget::runCMake() +{ + // TODO skip build directory + CMakeOpenProjectWizard copw(m_project->projectManager(), + m_project->projectDirectory(), + m_buildConfiguration->buildDirectory(), + CMakeOpenProjectWizard::WantToUpdate, + m_buildConfiguration->environment()); + if (copw.exec() == QDialog::Accepted) { + m_project->parseCMakeLists(); + } +} + ///// // CMakeCbpParser //// diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h index 36f394595bf7c7666a1d5f5ac13314ea3ad08285..d9128daebd7e0a85ec127aef7297c0fab5da42d4 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.h +++ b/src/plugins/cmakeprojectmanager/cmakeproject.h @@ -215,6 +215,7 @@ public: virtual void init(ProjectExplorer::BuildConfiguration *bc); private slots: void openChangeBuildDirectoryDialog(); + void runCMake(); private: CMakeProject *m_project; QLineEdit *m_pathLineEdit;