summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp141
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp149
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectmanager.h39
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro8
-rw-r--r--src/plugins/cmakeprojectmanager/cmakesettingspage.cpp188
-rw-r--r--src/plugins/cmakeprojectmanager/cmakesettingspage.h81
-rw-r--r--src/plugins/cmakeprojectmanager/generatorinfo.cpp155
-rw-r--r--src/plugins/cmakeprojectmanager/generatorinfo.h69
8 files changed, 501 insertions, 329 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp
index 18355e7258..26bb9f6856 100644
--- a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp
@@ -31,6 +31,7 @@
#include "cmakeprojectmanager.h"
#include "cmakebuildconfiguration.h"
#include "cmakebuildinfo.h"
+#include "generatorinfo.h"
#include <coreplugin/icore.h>
#include <utils/hostosinfo.h>
@@ -70,146 +71,6 @@ using namespace CMakeProjectManager::Internal;
// |--> Page: Ask for cmd options, run generator
-namespace CMakeProjectManager {
-namespace Internal {
- class GeneratorInfo
- {
- Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::GeneratorInfo)
- public:
- enum Ninja { NoNinja, OfferNinja, ForceNinja };
- static QList<GeneratorInfo> generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool preferNinja, bool hasCodeBlocks);
-
- GeneratorInfo();
- explicit GeneratorInfo(ProjectExplorer::Kit *kit, bool ninja = false);
-
- ProjectExplorer::Kit *kit() const;
- bool isNinja() const;
-
- QString displayName() const;
- QByteArray generatorArgument() const;
- QByteArray generator() const;
-
- private:
- ProjectExplorer::Kit *m_kit;
- bool m_isNinja;
- };
-}
-}
-
-Q_DECLARE_METATYPE(CMakeProjectManager::Internal::GeneratorInfo);
-
-GeneratorInfo::GeneratorInfo()
- : m_kit(0), m_isNinja(false)
-{}
-
-GeneratorInfo::GeneratorInfo(ProjectExplorer::Kit *kit, bool ninja)
- : m_kit(kit), m_isNinja(ninja)
-{}
-
-ProjectExplorer::Kit *GeneratorInfo::kit() const
-{
- return m_kit;
-}
-
-bool GeneratorInfo::isNinja() const {
- return m_isNinja;
-}
-
-QByteArray GeneratorInfo::generator() const
-{
- if (!m_kit)
- return QByteArray();
- ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(m_kit);
- ProjectExplorer::Abi targetAbi = tc->targetAbi();
- if (m_isNinja) {
- return "Ninja";
- } else if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) {
- if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2005Flavor
- || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2008Flavor
- || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2010Flavor
- || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2012Flavor) {
- return "NMake Makefiles";
- } else if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) {
- if (Utils::HostOsInfo::isWindowsHost())
- return "MinGW Makefiles";
- else
- return "Unix Makefiles";
- }
- }
- return "Unix Makefiles";
-}
-
-QByteArray GeneratorInfo::generatorArgument() const
-{
- QByteArray tmp = generator();
- if (tmp.isEmpty())
- return tmp;
- return QByteArray("-GCodeBlocks - ") + tmp;
-}
-
-QString GeneratorInfo::displayName() const
-{
- if (!m_kit)
- return QString();
- if (m_isNinja)
- return tr("Ninja (%1)").arg(m_kit->displayName());
- ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(m_kit);
- ProjectExplorer::Abi targetAbi = tc->targetAbi();
- if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) {
- if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2005Flavor
- || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2008Flavor
- || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2010Flavor
- || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2012Flavor) {
- return tr("NMake Generator (%1)").arg(m_kit->displayName());
- } else if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) {
- if (Utils::HostOsInfo::isWindowsHost())
- return tr("MinGW Generator (%1)").arg(m_kit->displayName());
- else
- return tr("Unix Generator (%1)").arg(m_kit->displayName());
- }
- } else {
- // Non windows
- return tr("Unix Generator (%1)").arg(m_kit->displayName());
- }
- return QString();
-}
-
-QList<GeneratorInfo> GeneratorInfo::generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool preferNinja, bool hasCodeBlocks)
-{
- QList<GeneratorInfo> results;
- ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
- if (!tc)
- return results;
- Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(k);
- if (deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE
- && deviceType != RemoteLinux::Constants::GenericLinuxOsType)
- return results;
- ProjectExplorer::Abi targetAbi = tc->targetAbi();
- if (n != ForceNinja) {
- if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) {
- if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2005Flavor
- || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2008Flavor
- || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2010Flavor
- || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2012Flavor) {
- if (hasCodeBlocks)
- results << GeneratorInfo(k);
- } else if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) {
- results << GeneratorInfo(k);
- }
- } else {
- // Non windows
- results << GeneratorInfo(k);
- }
- }
- if (n != NoNinja) {
- if (preferNinja)
- results.prepend(GeneratorInfo(k, true));
- else
- results.append(GeneratorInfo(k, true));
- }
- return results;
-}
-
//////////////
/// CMakeOpenProjectWizard
//////////////
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
index a013af5332..6b080482a3 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
@@ -46,15 +46,8 @@
#include <utils/QtConcurrentTools>
#include <QtConcurrentRun>
#include <QCoreApplication>
-#include <QSettings>
#include <QDateTime>
-#include <QFormLayout>
-#include <QBoxLayout>
#include <QDesktopServices>
-#include <QApplication>
-#include <QLabel>
-#include <QGroupBox>
-#include <QSpacerItem>
using namespace CMakeProjectManager::Internal;
@@ -248,145 +241,3 @@ QString CMakeManager::qtVersionForQMake(const QString &qmakePath)
}
return QString();
}
-
-/////
-// CMakeSettingsPage
-////
-
-
-CMakeSettingsPage::CMakeSettingsPage()
- : m_pathchooser(0), m_preferNinja(0)
-{
- setId("Z.CMake");
- setDisplayName(tr("CMake"));
- setCategory(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY);
- setDisplayCategory(QCoreApplication::translate("ProjectExplorer",
- ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_TR_CATEGORY));
- setCategoryIcon(QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY_ICON));
-
- QSettings *settings = Core::ICore::settings();
- settings->beginGroup(QLatin1String("CMakeSettings"));
- m_cmakeValidatorForUser.setCMakeExecutable(settings->value(QLatin1String("cmakeExecutable")).toString());
- settings->endGroup();
-
- m_cmakeValidatorForSystem.setCMakeExecutable(findCmakeExecutable());
-}
-
-bool CMakeSettingsPage::isCMakeExecutableValid() const
-{
- if (m_cmakeValidatorForUser.isValid())
- return true;
-
- return m_cmakeValidatorForSystem.isValid();
-}
-
-CMakeSettingsPage::~CMakeSettingsPage()
-{
- m_cmakeValidatorForUser.cancel();
- m_cmakeValidatorForSystem.cancel();
-}
-
-QString CMakeSettingsPage::findCmakeExecutable() const
-{
- return Utils::Environment::systemEnvironment().searchInPath(QLatin1String("cmake"));
-}
-
-QWidget *CMakeSettingsPage::widget()
-{
- if (!m_widget) {
- m_widget = new QWidget;
- QFormLayout *formLayout = new QFormLayout(m_widget);
- formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
- m_pathchooser = new Utils::PathChooser;
- m_pathchooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
- m_pathchooser->setHistoryCompleter(QLatin1String("Cmake.Command.History"));
- formLayout->addRow(tr("Executable:"), m_pathchooser);
- formLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
-
- m_preferNinja = new QCheckBox(tr("Prefer Ninja generator (CMake 2.8.9 or higher required)"));
- formLayout->addRow(m_preferNinja);
- }
- m_pathchooser->setPath(m_cmakeValidatorForUser.cmakeExecutable());
- m_preferNinja->setChecked(preferNinja());
- return m_widget;
-}
-
-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();
-}
-
-void CMakeSettingsPage::apply()
-{
- if (!m_pathchooser) // page was never shown
- return;
- if (m_cmakeValidatorForUser.cmakeExecutable() != m_pathchooser->path())
- m_cmakeValidatorForUser.setCMakeExecutable(m_pathchooser->path());
- saveSettings();
-}
-
-void CMakeSettingsPage::finish()
-{
- delete m_widget;
-}
-
-QString CMakeSettingsPage::cmakeExecutable() const
-{
- if (!isCMakeExecutableValid())
- return QString();
-
- if (m_cmakeValidatorForUser.isValid())
- return m_cmakeValidatorForUser.cmakeExecutable();
- if (m_cmakeValidatorForSystem.isValid())
- return m_cmakeValidatorForSystem.cmakeExecutable();
- return QString();
-}
-
-void CMakeSettingsPage::setCMakeExecutable(const QString &executable)
-{
- if (m_cmakeValidatorForUser.cmakeExecutable() == executable)
- return;
- m_cmakeValidatorForUser.setCMakeExecutable(executable);
-}
-
-bool CMakeSettingsPage::hasCodeBlocksMsvcGenerator() const
-{
- if (m_cmakeValidatorForUser.isValid())
- return m_cmakeValidatorForUser.hasCodeBlocksMsvcGenerator();
- if (m_cmakeValidatorForSystem.isValid())
- return m_cmakeValidatorForSystem.hasCodeBlocksMsvcGenerator();
- return false;
-}
-
-bool CMakeSettingsPage::hasCodeBlocksNinjaGenerator() const
-{
- if (m_cmakeValidatorForUser.isValid())
- return m_cmakeValidatorForUser.hasCodeBlocksNinjaGenerator();
- if (m_cmakeValidatorForSystem.isValid())
- return m_cmakeValidatorForSystem.hasCodeBlocksNinjaGenerator();
- 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())
- return m_cmakeValidatorForUser.keywords();
-
- if (m_cmakeValidatorForSystem.isValid())
- return m_cmakeValidatorForSystem.keywords();
-
- return TextEditor::Keywords(QStringList(), QStringList(), QMap<QString, QStringList>());
-}
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h
index 0b3509b520..f0fe2d6603 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h
@@ -31,14 +31,11 @@
#define CMAKEPROJECTMANAGER_H
#include <projectexplorer/iprojectmanager.h>
-#include <coreplugin/dialogs/ioptionspage.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectnodes.h>
#include <coreplugin/icontext.h>
-#include <texteditor/codeassist/keywordscompletionassist.h>
#include <utils/environment.h>
-#include <utils/pathchooser.h>
#include <QAction>
#include <QCheckBox>
@@ -48,9 +45,7 @@
#include <QStringList>
#include <QVector>
-#include "cmakevalidator.h"
-
-QT_FORWARD_DECLARE_CLASS(QLabel)
+#include "cmakesettingspage.h"
namespace Utils { class QtcProcess; }
@@ -99,38 +94,6 @@ private:
ProjectExplorer::Project *m_contextProject;
};
-class CMakeSettingsPage : public Core::IOptionsPage
-{
- Q_OBJECT
-
-public:
- CMakeSettingsPage();
- ~CMakeSettingsPage();
-
- QWidget *widget();
- void apply();
- void finish();
-
- QString cmakeExecutable() const;
- void setCMakeExecutable(const QString &executable);
- bool isCMakeExecutableValid() const;
- bool hasCodeBlocksMsvcGenerator() const;
- bool hasCodeBlocksNinjaGenerator() const;
- bool preferNinja() const;
-
- TextEditor::Keywords keywords();
-
-private:
- void saveSettings() const;
- QString findCmakeExecutable() const;
-
- QPointer<QWidget> m_widget;
- Utils::PathChooser *m_pathchooser;
- QCheckBox *m_preferNinja;
- CMakeValidator m_cmakeValidatorForUser;
- CMakeValidator m_cmakeValidatorForSystem;
-};
-
} // namespace Internal
} // namespace CMakeProjectManager
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
index e0e8c8ce97..7c1203cf41 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
@@ -17,7 +17,9 @@ HEADERS = cmakebuildinfo.h \
cmakelocatorfilter.h \
cmakefilecompletionassist.h \
cmakevalidator.h \
- cmakeparser.h
+ cmakeparser.h \
+ generatorinfo.h \
+ cmakesettingspage.h
SOURCES = cmakeproject.cpp \
cmakeprojectplugin.cpp \
@@ -34,7 +36,9 @@ SOURCES = cmakeproject.cpp \
cmakelocatorfilter.cpp \
cmakefilecompletionassist.cpp \
cmakevalidator.cpp \
- cmakeparser.cpp
+ cmakeparser.cpp \
+ generatorinfo.cpp \
+ cmakesettingspage.cpp
RESOURCES += cmakeproject.qrc
diff --git a/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp b/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp
new file mode 100644
index 0000000000..bc1360cdb5
--- /dev/null
+++ b/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+#include "cmakesettingspage.h"
+
+#include <projectexplorer/projectexplorerconstants.h>
+#include <coreplugin/icore.h>
+#include <utils/environment.h>
+
+#include <QSettings>
+#include <QGroupBox>
+#include <QSpacerItem>
+#include <QFormLayout>
+#include <QBoxLayout>
+#include <QCheckBox>
+
+namespace CMakeProjectManager {
+namespace Internal {
+
+/////
+// CMakeSettingsPage
+////
+
+
+CMakeSettingsPage::CMakeSettingsPage()
+ : m_pathchooser(0), m_preferNinja(0)
+{
+ setId("Z.CMake");
+ setDisplayName(tr("CMake"));
+ setCategory(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY);
+ setDisplayCategory(QCoreApplication::translate("ProjectExplorer",
+ ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_TR_CATEGORY));
+ setCategoryIcon(QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY_ICON));
+
+ QSettings *settings = Core::ICore::settings();
+ settings->beginGroup(QLatin1String("CMakeSettings"));
+ m_cmakeValidatorForUser.setCMakeExecutable(settings->value(QLatin1String("cmakeExecutable")).toString());
+ settings->endGroup();
+
+ m_cmakeValidatorForSystem.setCMakeExecutable(findCmakeExecutable());
+}
+
+bool CMakeSettingsPage::isCMakeExecutableValid() const
+{
+ if (m_cmakeValidatorForUser.isValid())
+ return true;
+
+ return m_cmakeValidatorForSystem.isValid();
+}
+
+CMakeSettingsPage::~CMakeSettingsPage()
+{
+ m_cmakeValidatorForUser.cancel();
+ m_cmakeValidatorForSystem.cancel();
+}
+
+QString CMakeSettingsPage::findCmakeExecutable() const
+{
+ return Utils::Environment::systemEnvironment().searchInPath(QLatin1String("cmake"));
+}
+
+QWidget *CMakeSettingsPage::widget()
+{
+ if (!m_widget) {
+ m_widget = new QWidget;
+ QFormLayout *formLayout = new QFormLayout(m_widget);
+ formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
+ m_pathchooser = new Utils::PathChooser;
+ m_pathchooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
+ m_pathchooser->setHistoryCompleter(QLatin1String("Cmake.Command.History"));
+ formLayout->addRow(tr("Executable:"), m_pathchooser);
+ formLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
+
+ m_preferNinja = new QCheckBox(tr("Prefer Ninja generator (CMake 2.8.9 or higher required)"));
+ formLayout->addRow(m_preferNinja);
+ }
+ m_pathchooser->setPath(m_cmakeValidatorForUser.cmakeExecutable());
+ m_preferNinja->setChecked(preferNinja());
+ return m_widget;
+}
+
+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();
+}
+
+void CMakeSettingsPage::apply()
+{
+ if (!m_pathchooser) // page was never shown
+ return;
+ if (m_cmakeValidatorForUser.cmakeExecutable() != m_pathchooser->path())
+ m_cmakeValidatorForUser.setCMakeExecutable(m_pathchooser->path());
+ saveSettings();
+}
+
+void CMakeSettingsPage::finish()
+{
+ delete m_widget;
+}
+
+QString CMakeSettingsPage::cmakeExecutable() const
+{
+ if (!isCMakeExecutableValid())
+ return QString();
+
+ if (m_cmakeValidatorForUser.isValid())
+ return m_cmakeValidatorForUser.cmakeExecutable();
+ if (m_cmakeValidatorForSystem.isValid())
+ return m_cmakeValidatorForSystem.cmakeExecutable();
+ return QString();
+}
+
+void CMakeSettingsPage::setCMakeExecutable(const QString &executable)
+{
+ if (m_cmakeValidatorForUser.cmakeExecutable() == executable)
+ return;
+ m_cmakeValidatorForUser.setCMakeExecutable(executable);
+}
+
+bool CMakeSettingsPage::hasCodeBlocksMsvcGenerator() const
+{
+ if (m_cmakeValidatorForUser.isValid())
+ return m_cmakeValidatorForUser.hasCodeBlocksMsvcGenerator();
+ if (m_cmakeValidatorForSystem.isValid())
+ return m_cmakeValidatorForSystem.hasCodeBlocksMsvcGenerator();
+ return false;
+}
+
+bool CMakeSettingsPage::hasCodeBlocksNinjaGenerator() const
+{
+ if (m_cmakeValidatorForUser.isValid())
+ return m_cmakeValidatorForUser.hasCodeBlocksNinjaGenerator();
+ if (m_cmakeValidatorForSystem.isValid())
+ return m_cmakeValidatorForSystem.hasCodeBlocksNinjaGenerator();
+ 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())
+ return m_cmakeValidatorForUser.keywords();
+
+ if (m_cmakeValidatorForSystem.isValid())
+ return m_cmakeValidatorForSystem.keywords();
+
+ return TextEditor::Keywords(QStringList(), QStringList(), QMap<QString, QStringList>());
+}
+
+} // namespace Internal
+} // namespace CMakeProjectManager
diff --git a/src/plugins/cmakeprojectmanager/cmakesettingspage.h b/src/plugins/cmakeprojectmanager/cmakesettingspage.h
new file mode 100644
index 0000000000..86f62693cd
--- /dev/null
+++ b/src/plugins/cmakeprojectmanager/cmakesettingspage.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+#ifndef CMAKEPROJECTMANAGER_INTERNAL_CMAKESETTINGSPAGE_H
+#define CMAKEPROJECTMANAGER_INTERNAL_CMAKESETTINGSPAGE_H
+
+#include <coreplugin/dialogs/ioptionspage.h>
+#include <utils/pathchooser.h>
+#include <texteditor/codeassist/keywordscompletionassist.h>
+
+#include <QPointer>
+
+#include "cmakevalidator.h"
+
+QT_FORWARD_DECLARE_CLASS(QLabel)
+QT_FORWARD_DECLARE_CLASS(QCheckBox)
+
+namespace CMakeProjectManager {
+namespace Internal {
+
+class CMakeSettingsPage : public Core::IOptionsPage
+{
+ Q_OBJECT
+
+public:
+ CMakeSettingsPage();
+ ~CMakeSettingsPage();
+
+ QWidget *widget();
+ void apply();
+ void finish();
+
+ QString cmakeExecutable() const;
+ void setCMakeExecutable(const QString &executable);
+ bool isCMakeExecutableValid() const;
+ bool hasCodeBlocksMsvcGenerator() const;
+ bool hasCodeBlocksNinjaGenerator() const;
+ bool preferNinja() const;
+
+ TextEditor::Keywords keywords();
+
+private:
+ void saveSettings() const;
+ QString findCmakeExecutable() const;
+
+ QPointer<QWidget> m_widget;
+ Utils::PathChooser *m_pathchooser;
+ QCheckBox *m_preferNinja;
+ CMakeValidator m_cmakeValidatorForUser;
+ CMakeValidator m_cmakeValidatorForSystem;
+};
+
+} // namespace Internal
+} // namespace CMakeProjectManager
+
+#endif // CMAKEPROJECTMANAGER_INTERNAL_CMAKESETTINGSPAGE_H
diff --git a/src/plugins/cmakeprojectmanager/generatorinfo.cpp b/src/plugins/cmakeprojectmanager/generatorinfo.cpp
new file mode 100644
index 0000000000..c3543e9d86
--- /dev/null
+++ b/src/plugins/cmakeprojectmanager/generatorinfo.cpp
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "generatorinfo.h"
+
+#include <projectexplorer/projectexplorerconstants.h>
+#include <projectexplorer/toolchain.h>
+#include <projectexplorer/abi.h>
+#include <projectexplorer/kitinformation.h>
+
+#include <remotelinux/remotelinux_constants.h>
+
+namespace CMakeProjectManager {
+namespace Internal {
+
+GeneratorInfo::GeneratorInfo()
+ : m_kit(0), m_isNinja(false)
+{}
+
+GeneratorInfo::GeneratorInfo(ProjectExplorer::Kit *kit, bool ninja)
+ : m_kit(kit), m_isNinja(ninja)
+{}
+
+ProjectExplorer::Kit *GeneratorInfo::kit() const
+{
+ return m_kit;
+}
+
+bool GeneratorInfo::isNinja() const {
+ return m_isNinja;
+}
+
+QByteArray GeneratorInfo::generator() const
+{
+ if (!m_kit)
+ return QByteArray();
+ ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(m_kit);
+ ProjectExplorer::Abi targetAbi = tc->targetAbi();
+ if (m_isNinja) {
+ return "Ninja";
+ } else if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) {
+ if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2005Flavor
+ || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2008Flavor
+ || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2010Flavor
+ || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2012Flavor) {
+ return "NMake Makefiles";
+ } else if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) {
+ if (Utils::HostOsInfo::isWindowsHost())
+ return "MinGW Makefiles";
+ else
+ return "Unix Makefiles";
+ }
+ }
+ return "Unix Makefiles";
+}
+
+QByteArray GeneratorInfo::generatorArgument() const
+{
+ QByteArray tmp = generator();
+ if (tmp.isEmpty())
+ return tmp;
+ return QByteArray("-GCodeBlocks - ") + tmp;
+}
+
+QString GeneratorInfo::displayName() const
+{
+ if (!m_kit)
+ return QString();
+ if (m_isNinja)
+ return tr("Ninja (%1)").arg(m_kit->displayName());
+ ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(m_kit);
+ ProjectExplorer::Abi targetAbi = tc->targetAbi();
+ if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) {
+ if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2005Flavor
+ || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2008Flavor
+ || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2010Flavor
+ || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2012Flavor) {
+ return tr("NMake Generator (%1)").arg(m_kit->displayName());
+ } else if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) {
+ if (Utils::HostOsInfo::isWindowsHost())
+ return tr("MinGW Generator (%1)").arg(m_kit->displayName());
+ else
+ return tr("Unix Generator (%1)").arg(m_kit->displayName());
+ }
+ } else {
+ // Non windows
+ return tr("Unix Generator (%1)").arg(m_kit->displayName());
+ }
+ return QString();
+}
+
+QList<GeneratorInfo> GeneratorInfo::generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool preferNinja, bool hasCodeBlocks)
+{
+ QList<GeneratorInfo> results;
+ ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
+ if (!tc)
+ return results;
+ Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(k);
+ if (deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE
+ && deviceType != RemoteLinux::Constants::GenericLinuxOsType)
+ return results;
+ ProjectExplorer::Abi targetAbi = tc->targetAbi();
+ if (n != ForceNinja) {
+ if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) {
+ if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2005Flavor
+ || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2008Flavor
+ || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2010Flavor
+ || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2012Flavor) {
+ if (hasCodeBlocks)
+ results << GeneratorInfo(k);
+ } else if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) {
+ results << GeneratorInfo(k);
+ }
+ } else {
+ // Non windows
+ results << GeneratorInfo(k);
+ }
+ }
+ if (n != NoNinja) {
+ if (preferNinja)
+ results.prepend(GeneratorInfo(k, true));
+ else
+ results.append(GeneratorInfo(k, true));
+ }
+ return results;
+}
+
+} // namespace Internal
+} // namespace CMakeProjectManager
diff --git a/src/plugins/cmakeprojectmanager/generatorinfo.h b/src/plugins/cmakeprojectmanager/generatorinfo.h
new file mode 100644
index 0000000000..d016d94152
--- /dev/null
+++ b/src/plugins/cmakeprojectmanager/generatorinfo.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+#ifndef CMAKEPROJECTMANAGER_INTERNAL_GENERATORINFO_H
+#define CMAKEPROJECTMANAGER_INTERNAL_GENERATORINFO_H
+
+#include "cmakeprojectmanager.h"
+
+#include <projectexplorer/kit.h>
+
+#include <QCoreApplication>
+#include <QMetaType>
+
+namespace CMakeProjectManager {
+namespace Internal {
+
+class GeneratorInfo
+{
+ Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::GeneratorInfo)
+public:
+ enum Ninja { NoNinja, OfferNinja, ForceNinja };
+ static QList<GeneratorInfo> generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool preferNinja, bool hasCodeBlocks);
+
+ GeneratorInfo();
+ explicit GeneratorInfo(ProjectExplorer::Kit *kit, bool ninja = false);
+
+ ProjectExplorer::Kit *kit() const;
+ bool isNinja() const;
+
+ QString displayName() const;
+ QByteArray generatorArgument() const;
+ QByteArray generator() const;
+
+private:
+ ProjectExplorer::Kit *m_kit;
+ bool m_isNinja;
+};
+
+} // namespace Internal
+} // namespace CMakeProjectManager
+
+Q_DECLARE_METATYPE(CMakeProjectManager::Internal::GeneratorInfo)
+
+#endif // CMAKEPROJECTMANAGER_INTERNAL_GENERATORINFO_H