forked from qt-creator/qt-creator
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:
committed by
Peter Kümmel
parent
a436ffc0b9
commit
75d1c3035a
@@ -74,7 +74,7 @@ namespace Internal {
|
|||||||
Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::GeneratorInfo)
|
Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::GeneratorInfo)
|
||||||
public:
|
public:
|
||||||
enum Ninja { NoNinja, OfferNinja, ForceNinja };
|
enum Ninja { NoNinja, OfferNinja, ForceNinja };
|
||||||
static QList<GeneratorInfo> generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool hasCodeBlocks);
|
static QList<GeneratorInfo> generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool preferNinja, bool hasCodeBlocks);
|
||||||
|
|
||||||
GeneratorInfo();
|
GeneratorInfo();
|
||||||
explicit GeneratorInfo(ProjectExplorer::Kit *kit, bool ninja = false);
|
explicit GeneratorInfo(ProjectExplorer::Kit *kit, bool ninja = false);
|
||||||
@@ -171,7 +171,7 @@ QString GeneratorInfo::displayName() const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<GeneratorInfo> GeneratorInfo::generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool hasCodeBlocks)
|
QList<GeneratorInfo> GeneratorInfo::generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool preferNinja, bool hasCodeBlocks)
|
||||||
{
|
{
|
||||||
QList<GeneratorInfo> results;
|
QList<GeneratorInfo> results;
|
||||||
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
|
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
|
||||||
@@ -194,8 +194,12 @@ QList<GeneratorInfo> GeneratorInfo::generatorInfosFor(ProjectExplorer::Kit *k, N
|
|||||||
results << GeneratorInfo(k);
|
results << GeneratorInfo(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (n != NoNinja)
|
if (n != NoNinja) {
|
||||||
results << GeneratorInfo(k, true);
|
if (preferNinja)
|
||||||
|
results.prepend(GeneratorInfo(k, true));
|
||||||
|
else
|
||||||
|
results.append(GeneratorInfo(k, true));
|
||||||
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,6 +285,7 @@ bool CMakeOpenProjectWizard::compatibleKitExist() const
|
|||||||
{
|
{
|
||||||
bool hasCodeBlocksGenerator = m_cmakeManager->hasCodeBlocksMsvcGenerator();
|
bool hasCodeBlocksGenerator = m_cmakeManager->hasCodeBlocksMsvcGenerator();
|
||||||
bool hasNinjaGenerator = m_cmakeManager->hasCodeBlocksNinjaGenerator();
|
bool hasNinjaGenerator = m_cmakeManager->hasCodeBlocksNinjaGenerator();
|
||||||
|
bool preferNinja = m_cmakeManager->preferNinja();
|
||||||
|
|
||||||
QList<ProjectExplorer::Kit *> kitList =
|
QList<ProjectExplorer::Kit *> kitList =
|
||||||
ProjectExplorer::KitManager::instance()->kits();
|
ProjectExplorer::KitManager::instance()->kits();
|
||||||
@@ -291,6 +296,7 @@ bool CMakeOpenProjectWizard::compatibleKitExist() const
|
|||||||
// are interested in here
|
// are interested in here
|
||||||
QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(k,
|
QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(k,
|
||||||
hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja,
|
hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja,
|
||||||
|
preferNinja,
|
||||||
hasCodeBlocksGenerator);
|
hasCodeBlocksGenerator);
|
||||||
if (!infos.isEmpty())
|
if (!infos.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
@@ -647,6 +653,7 @@ void CMakeRunPage::initializePage()
|
|||||||
|
|
||||||
bool hasCodeBlocksGenerator = m_cmakeWizard->cmakeManager()->hasCodeBlocksMsvcGenerator();
|
bool hasCodeBlocksGenerator = m_cmakeWizard->cmakeManager()->hasCodeBlocksMsvcGenerator();
|
||||||
bool hasNinjaGenerator = m_cmakeWizard->cmakeManager()->hasCodeBlocksNinjaGenerator();
|
bool hasNinjaGenerator = m_cmakeWizard->cmakeManager()->hasCodeBlocksNinjaGenerator();
|
||||||
|
bool preferNinja = m_cmakeWizard->cmakeManager()->preferNinja();
|
||||||
|
|
||||||
if (m_mode == Initial) {
|
if (m_mode == Initial) {
|
||||||
// Try figuring out generator and toolchain from CMakeCache.txt
|
// Try figuring out generator and toolchain from CMakeCache.txt
|
||||||
@@ -659,6 +666,7 @@ void CMakeRunPage::initializePage()
|
|||||||
foreach (ProjectExplorer::Kit *k, kitList) {
|
foreach (ProjectExplorer::Kit *k, kitList) {
|
||||||
QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(k,
|
QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(k,
|
||||||
hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja,
|
hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja,
|
||||||
|
preferNinja,
|
||||||
hasCodeBlocksGenerator);
|
hasCodeBlocksGenerator);
|
||||||
|
|
||||||
foreach (const GeneratorInfo &info, infos)
|
foreach (const GeneratorInfo &info, infos)
|
||||||
@@ -680,6 +688,7 @@ void CMakeRunPage::initializePage()
|
|||||||
|
|
||||||
QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(m_cmakeWizard->kit(),
|
QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(m_cmakeWizard->kit(),
|
||||||
ninja,
|
ninja,
|
||||||
|
preferNinja,
|
||||||
true);
|
true);
|
||||||
foreach (const GeneratorInfo &info, infos)
|
foreach (const GeneratorInfo &info, infos)
|
||||||
m_generatorComboBox->addItem(info.displayName(), qVariantFromValue(info));
|
m_generatorComboBox->addItem(info.displayName(), qVariantFromValue(info));
|
||||||
|
|||||||
@@ -161,6 +161,11 @@ bool CMakeManager::hasCodeBlocksNinjaGenerator() const
|
|||||||
return m_settingsPage->hasCodeBlocksNinjaGenerator();
|
return m_settingsPage->hasCodeBlocksNinjaGenerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CMakeManager::preferNinja() const
|
||||||
|
{
|
||||||
|
return m_settingsPage->preferNinja();
|
||||||
|
}
|
||||||
|
|
||||||
// need to refactor this out
|
// need to refactor this out
|
||||||
// we probably want the process instead of this function
|
// we probably want the process instead of this function
|
||||||
// cmakeproject then could even run the cmake process in the background, adding the files afterwards
|
// 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()
|
CMakeSettingsPage::CMakeSettingsPage()
|
||||||
: m_pathchooser(0)
|
: m_pathchooser(0), m_preferNinja(0)
|
||||||
{
|
{
|
||||||
setId("Z.CMake");
|
setId("Z.CMake");
|
||||||
setDisplayName(tr("CMake"));
|
setDisplayName(tr("CMake"));
|
||||||
@@ -288,6 +293,11 @@ QWidget *CMakeSettingsPage::createPage(QWidget *parent)
|
|||||||
formLayout->addRow(tr("Executable:"), m_pathchooser);
|
formLayout->addRow(tr("Executable:"), m_pathchooser);
|
||||||
formLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
|
formLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
|
||||||
m_pathchooser->setPath(m_cmakeValidatorForUser.cmakeExecutable());
|
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;
|
return outerWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,6 +306,7 @@ void CMakeSettingsPage::saveSettings() const
|
|||||||
QSettings *settings = Core::ICore::settings();
|
QSettings *settings = Core::ICore::settings();
|
||||||
settings->beginGroup(QLatin1String("CMakeSettings"));
|
settings->beginGroup(QLatin1String("CMakeSettings"));
|
||||||
settings->setValue(QLatin1String("cmakeExecutable"), m_cmakeValidatorForUser.cmakeExecutable());
|
settings->setValue(QLatin1String("cmakeExecutable"), m_cmakeValidatorForUser.cmakeExecutable());
|
||||||
|
settings->setValue(QLatin1String("preferNinja"), m_preferNinja->isChecked());
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,8 +314,7 @@ void CMakeSettingsPage::apply()
|
|||||||
{
|
{
|
||||||
if (!m_pathchooser) // page was never shown
|
if (!m_pathchooser) // page was never shown
|
||||||
return;
|
return;
|
||||||
if (m_cmakeValidatorForUser.cmakeExecutable() == m_pathchooser->path())
|
if (m_cmakeValidatorForUser.cmakeExecutable() != m_pathchooser->path())
|
||||||
return;
|
|
||||||
m_cmakeValidatorForUser.setCMakeExecutable(m_pathchooser->path());
|
m_cmakeValidatorForUser.setCMakeExecutable(m_pathchooser->path());
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
@@ -351,6 +361,15 @@ bool CMakeSettingsPage::hasCodeBlocksNinjaGenerator() const
|
|||||||
return false;
|
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()
|
TextEditor::Keywords CMakeSettingsPage::keywords()
|
||||||
{
|
{
|
||||||
if (m_cmakeValidatorForUser.isValid())
|
if (m_cmakeValidatorForUser.isValid())
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
@@ -81,6 +82,7 @@ public:
|
|||||||
const QString &generator);
|
const QString &generator);
|
||||||
bool hasCodeBlocksMsvcGenerator() const;
|
bool hasCodeBlocksMsvcGenerator() const;
|
||||||
bool hasCodeBlocksNinjaGenerator() const;
|
bool hasCodeBlocksNinjaGenerator() const;
|
||||||
|
bool preferNinja() const;
|
||||||
static QString findCbpFile(const QDir &);
|
static QString findCbpFile(const QDir &);
|
||||||
|
|
||||||
static QString findDumperLibrary(const Utils::Environment &env);
|
static QString findDumperLibrary(const Utils::Environment &env);
|
||||||
@@ -115,6 +117,7 @@ public:
|
|||||||
bool isCMakeExecutableValid() const;
|
bool isCMakeExecutableValid() const;
|
||||||
bool hasCodeBlocksMsvcGenerator() const;
|
bool hasCodeBlocksMsvcGenerator() const;
|
||||||
bool hasCodeBlocksNinjaGenerator() const;
|
bool hasCodeBlocksNinjaGenerator() const;
|
||||||
|
bool preferNinja() const;
|
||||||
|
|
||||||
TextEditor::Keywords keywords();
|
TextEditor::Keywords keywords();
|
||||||
|
|
||||||
@@ -123,6 +126,7 @@ private:
|
|||||||
QString findCmakeExecutable() const;
|
QString findCmakeExecutable() const;
|
||||||
|
|
||||||
Utils::PathChooser *m_pathchooser;
|
Utils::PathChooser *m_pathchooser;
|
||||||
|
QCheckBox *m_preferNinja;
|
||||||
CMakeValidator m_cmakeValidatorForUser;
|
CMakeValidator m_cmakeValidatorForUser;
|
||||||
CMakeValidator m_cmakeValidatorForSystem;
|
CMakeValidator m_cmakeValidatorForSystem;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user