CMake: Add option for preferred Ninja user

Change-Id: I5a3aa31db7fa37f31a4b557eb5b09b7987169265
Reviewed-by: Peter Kümmel <syntheticpp@gmx.net>
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
Yuchen Deng
2013-02-16 14:54:13 +08:00
committed by Peter Kümmel
parent a436ffc0b9
commit 75d1c3035a
3 changed files with 40 additions and 8 deletions

View File

@@ -161,6 +161,11 @@ bool CMakeManager::hasCodeBlocksNinjaGenerator() const
return m_settingsPage->hasCodeBlocksNinjaGenerator();
}
bool CMakeManager::preferNinja() const
{
return m_settingsPage->preferNinja();
}
// need to refactor this out
// we probably want the process instead of this function
// cmakeproject then could even run the cmake process in the background, adding the files afterwards
@@ -241,7 +246,7 @@ QString CMakeManager::qtVersionForQMake(const QString &qmakePath)
CMakeSettingsPage::CMakeSettingsPage()
: m_pathchooser(0)
: m_pathchooser(0), m_preferNinja(0)
{
setId("Z.CMake");
setDisplayName(tr("CMake"));
@@ -288,6 +293,11 @@ QWidget *CMakeSettingsPage::createPage(QWidget *parent)
formLayout->addRow(tr("Executable:"), m_pathchooser);
formLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
m_pathchooser->setPath(m_cmakeValidatorForUser.cmakeExecutable());
m_preferNinja = new QCheckBox(tr("Prefer Ninja generator (CMake 2.8.9 or higher required)"));
m_preferNinja->setChecked(preferNinja());
formLayout->addRow(m_preferNinja);
return outerWidget;
}
@@ -296,6 +306,7 @@ void CMakeSettingsPage::saveSettings() const
QSettings *settings = Core::ICore::settings();
settings->beginGroup(QLatin1String("CMakeSettings"));
settings->setValue(QLatin1String("cmakeExecutable"), m_cmakeValidatorForUser.cmakeExecutable());
settings->setValue(QLatin1String("preferNinja"), m_preferNinja->isChecked());
settings->endGroup();
}
@@ -303,9 +314,8 @@ void CMakeSettingsPage::apply()
{
if (!m_pathchooser) // page was never shown
return;
if (m_cmakeValidatorForUser.cmakeExecutable() == m_pathchooser->path())
return;
m_cmakeValidatorForUser.setCMakeExecutable(m_pathchooser->path());
if (m_cmakeValidatorForUser.cmakeExecutable() != m_pathchooser->path())
m_cmakeValidatorForUser.setCMakeExecutable(m_pathchooser->path());
saveSettings();
}
@@ -351,6 +361,15 @@ bool CMakeSettingsPage::hasCodeBlocksNinjaGenerator() const
return false;
}
bool CMakeSettingsPage::preferNinja() const
{
QSettings *settings = Core::ICore::settings();
settings->beginGroup(QLatin1String("CMakeSettings"));
const bool r = settings->value(QLatin1String("preferNinja"), false).toBool();
settings->endGroup();
return r;
}
TextEditor::Keywords CMakeSettingsPage::keywords()
{
if (m_cmakeValidatorForUser.isValid())