diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index c9ef999cf4a5cf83585bdf60073f2256870c1c7d..3b71d8c8b6f41ac5b19f49f1c7f025439965d2ac 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -74,6 +74,9 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName) m_watcher = new ProjectExplorer::FileWatcher(this); connect(m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(fileChanged(QString))); m_watcher->addFile(fileName); + + connect(this, SIGNAL(activeBuildConfigurationChanged()), + this, SLOT(slotActiveBuildConfiguration())); } CMakeProject::~CMakeProject() @@ -82,6 +85,28 @@ CMakeProject::~CMakeProject() delete m_toolChain; } +void CMakeProject::slotActiveBuildConfiguration() +{ + // Pop up a dialog asking the user to rerun cmake + QFileInfo sourceFileInfo(m_fileName); + QStringList needToCreate; + QStringList needToUpdate; + + QString cbpFile = CMakeManager::findCbpFile(QDir(buildDirectory(activeBuildConfiguration()))); + QFileInfo cbpFileFi(cbpFile); + if (!cbpFileFi.exists()) + needToCreate << buildDirectory(activeBuildConfiguration()); + else if (cbpFileFi.lastModified() < sourceFileInfo.lastModified()) + needToUpdate << buildDirectory(activeBuildConfiguration()); + + if (!needToCreate.isEmpty() || !needToUpdate.isEmpty()) { + CMakeOpenProjectWizard copw(m_manager, sourceFileInfo.absolutePath(), needToCreate, needToUpdate); + copw.exec(); + } + // reparse + parseCMakeLists(); +} + void CMakeProject::fileChanged(const QString &fileName) { if (m_insideFileChanged== true) @@ -89,26 +114,7 @@ void CMakeProject::fileChanged(const QString &fileName) m_insideFileChanged = true; if (fileName == m_fileName) { // Oh we have changed... - - // Pop up a dialog asking the user to rerun cmake - QFileInfo sourceFileInfo(m_fileName); - QStringList needToCreate; - QStringList needToUpdate; - foreach(const QString &buildConfiguration, buildConfigurations()) { - QString buildDirectory = value(buildConfiguration, "buildDirectory").toString(); - QString cbpFile = CMakeManager::findCbpFile(QDir(buildDirectory)); - QFileInfo cbpFileFi(cbpFile); - if (!cbpFileFi.exists()) - needToCreate << buildDirectory; - else if (cbpFileFi.lastModified() < sourceFileInfo.lastModified()) - needToUpdate << buildDirectory; - } - if (!needToCreate.isEmpty() || !needToUpdate.isEmpty()) { - CMakeOpenProjectWizard copw(m_manager, sourceFileInfo.absolutePath(), needToCreate, needToUpdate); - copw.exec(); - } - // reparse - parseCMakeLists(); + slotActiveBuildConfiguration(); } m_insideFileChanged = false; } @@ -461,6 +467,12 @@ QList<ProjectExplorer::BuildStepConfigWidget*> CMakeProject::subConfigWidgets() { // Default to all makeStep()->setBuildTarget(buildConfiguration, "all", true); + + CMakeOpenProjectWizard copw(projectManager(), sourceDirectory(), buildDirectory(buildConfiguration)); + if (copw.exec() == QDialog::Accepted) { + setValue(buildConfiguration, "buildDirectory", copw.buildDirectory()); + parseCMakeLists(); + } } ProjectExplorer::ProjectNode *CMakeProject::rootProjectNode() const @@ -526,15 +538,13 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader QFileInfo sourceFileInfo(m_fileName); QStringList needToCreate; QStringList needToUpdate; - foreach(const QString &buildConfiguration, buildConfigurations()) { - QString buildDirectory = value(buildConfiguration, "buildDirectory").toString(); - QString cbpFile = CMakeManager::findCbpFile(QDir(buildDirectory)); - QFileInfo cbpFileFi(cbpFile); - if (!cbpFileFi.exists()) - needToCreate << buildDirectory; - else if (cbpFileFi.lastModified() < sourceFileInfo.lastModified()) - needToUpdate << buildDirectory; - } + QString cbpFile = CMakeManager::findCbpFile(QDir(buildDirectory(activeBuildConfiguration()))); + QFileInfo cbpFileFi(cbpFile); + if (!cbpFileFi.exists()) + needToCreate << buildDirectory(activeBuildConfiguration()); + else if (cbpFileFi.lastModified() < sourceFileInfo.lastModified()) + needToUpdate << buildDirectory(activeBuildConfiguration()); + if (!needToCreate.isEmpty() || !needToUpdate.isEmpty()) { CMakeOpenProjectWizard copw(m_manager, sourceFileInfo.absolutePath(), needToCreate, needToUpdate); copw.exec(); @@ -642,7 +652,7 @@ void CMakeBuildSettingsWidget::init(const QString &buildConfiguration) if (m_project->buildDirectory(buildConfiguration) == m_project->sourceDirectory()) m_changeButton->setEnabled(false); else - m_changeButton->setEnabled(false); + m_changeButton->setEnabled(true); } void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog() diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h index 8de6ea42b0911e3a7ed68f5a3ae40e8958a08d5a..b8ec6a0215f21e10d54a0be4c89307d2a4f56bb9 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.h +++ b/src/plugins/cmakeprojectmanager/cmakeproject.h @@ -108,6 +108,7 @@ protected: private slots: void fileChanged(const QString &fileName); + void slotActiveBuildConfiguration(); private: void parseCMakeLists();