aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeproject.h1
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp131
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectmanager.h33
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro1
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp4
-rw-r--r--src/plugins/projectexplorer/environment.cpp4
6 files changed, 167 insertions, 7 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h
index a71ca7c8b00..e07c4106d4b 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.h
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.h
@@ -105,6 +105,7 @@ public:
CMakeStep *cmakeStep() const;
QStringList targets() const;
+
private:
void parseCMakeLists(const QDir &directory);
QString findCbpFile(const QDir &);
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
index 845255eda5d..d8511011c36 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
@@ -38,16 +38,25 @@
#include <coreplugin/uniqueidmanager.h>
#include <projectexplorer/projectexplorerconstants.h>
+#include <projectexplorer/environment.h>
+#include <QtCore/QSettings>
+#include <QFormLayout>
using namespace CMakeProjectManager::Internal;
-CMakeManager::CMakeManager()
+CMakeManager::CMakeManager(CMakeSettingsPage *cmakeSettingsPage)
+ : m_settingsPage(cmakeSettingsPage)
{
Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance();
m_projectContext = uidm->uniqueIdentifier(CMakeProjectManager::Constants::PROJECTCONTEXT);
m_projectLanguage = uidm->uniqueIdentifier(ProjectExplorer::Constants::LANG_CXX);
}
+CMakeSettingsPage::~CMakeSettingsPage()
+{
+
+}
+
int CMakeManager::projectContext() const
{
return m_projectContext;
@@ -61,6 +70,14 @@ int CMakeManager::projectLanguage() const
ProjectExplorer::Project *CMakeManager::openProject(const QString &fileName)
{
// TODO check wheter this project is already opened
+ // Check that we have a cmake executable first
+ // Look at the settings first
+ QString cmakeExecutable = m_settingsPage->cmakeExecutable();
+ if (cmakeExecutable.isNull())
+ m_settingsPage->askUserForCMakeExecutable();
+ cmakeExecutable = m_settingsPage->cmakeExecutable();
+ if (cmakeExecutable.isNull())
+ return 0;
return new CMakeProject(this, fileName);
}
@@ -68,3 +85,115 @@ QString CMakeManager::mimeType() const
{
return Constants::CMAKEMIMETYPE;
}
+
+/////
+// CMakeSettingsPage
+////
+
+CMakeSettingsPage::CMakeSettingsPage()
+{
+ Core::ICore *core = Core::ICore::instance();
+ QSettings * settings = core->settings();
+ settings->beginGroup("CMakeSettings");
+ m_cmakeExecutable = settings->value("cmakeExecutable").toString();
+ settings->endGroup();
+ updateCachedInformation();
+}
+
+void CMakeSettingsPage::updateCachedInformation() const
+{
+ // We find out two things:
+ // Does this cmake version support a QtCreator generator
+ // and the version
+ QFileInfo fi(m_cmakeExecutable);
+ if (!fi.exists()) {
+ m_version.clear();
+ m_supportsQtCreator = false;
+ }
+ QProcess cmake;
+ cmake.start(m_cmakeExecutable, QStringList()<<"--help");
+ cmake.waitForFinished();
+ QString response = cmake.readAll();
+ QRegExp versionRegexp("^cmake version ([*\\d\\.]*)-(|patch (\\d*))(|\\r)\\n");
+ versionRegexp.indexIn(response);
+
+ m_supportsQtCreator = response.contains("QtCreator");
+ m_version = versionRegexp.cap(1);
+ if (!versionRegexp.capturedTexts().size()>3)
+ m_version += "." + versionRegexp.cap(3);
+}
+
+QString CMakeSettingsPage::findCmakeExecutable() const
+{
+ ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
+ return env.searchInPath("cmake");
+}
+
+
+QString CMakeSettingsPage::name() const
+{
+ return "CMake";
+}
+
+QString CMakeSettingsPage::category() const
+{
+ return "CMake";
+}
+
+QString CMakeSettingsPage::trCategory() const
+{
+ return tr("CMake");
+}
+
+QWidget *CMakeSettingsPage::createPage(QWidget *parent)
+{
+ QWidget *w = new QWidget(parent);
+ QFormLayout *fl = new QFormLayout(w);
+ m_pathchooser = new Core::Utils::PathChooser(w);
+ m_pathchooser->setExpectedKind(Core::Utils::PathChooser::Command);
+ fl->addRow("CMake executable", m_pathchooser);
+ m_pathchooser->setPath(cmakeExecutable());
+ return w;
+}
+
+void CMakeSettingsPage::saveSettings() const
+{
+ QSettings *settings = Core::ICore::instance()->settings();
+ settings->beginGroup("CMakeSettings");
+ settings->setValue("cmakeExecutable", m_cmakeExecutable);
+ settings->endGroup();
+}
+
+void CMakeSettingsPage::apply()
+{
+ m_cmakeExecutable = m_pathchooser->path();
+ updateCachedInformation();
+ saveSettings();
+}
+
+void CMakeSettingsPage::finish()
+{
+
+}
+
+QString CMakeSettingsPage::cmakeExecutable() const
+{
+ if (m_cmakeExecutable.isEmpty()) {
+ m_cmakeExecutable = findCmakeExecutable();
+ if (!m_cmakeExecutable.isEmpty()) {
+ updateCachedInformation();
+ saveSettings();
+ }
+ }
+ return m_cmakeExecutable;
+}
+
+void CMakeSettingsPage::askUserForCMakeExecutable()
+{
+ // TODO implement
+ // That is ideally add a label to the settings page, which says something
+ // to the effect: please configure the cmake executable
+ // and show the settings page
+ // ensure that we rehide the label in the finish() function
+ // But to test that i need an environment without cmake, e.g. windows
+}
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h
index 34d97f1cc7c..49e6ac8846e 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h
@@ -34,16 +34,20 @@
#ifndef CMAKEPROJECTMANAGER_H
#define CMAKEPROJECTMANAGER_H
+#include <coreplugin/dialogs/ioptionspage.h>
#include <projectexplorer/iprojectmanager.h>
+#include <utils/pathchooser.h>
namespace CMakeProjectManager {
namespace Internal {
+class CMakeSettingsPage;
+
class CMakeManager : public ProjectExplorer::IProjectManager
{
Q_OBJECT
public:
- CMakeManager();
+ CMakeManager(CMakeSettingsPage *cmakeSettingsPage);
virtual int projectContext() const;
virtual int projectLanguage() const;
@@ -55,6 +59,33 @@ public:
private:
int m_projectContext;
int m_projectLanguage;
+ CMakeSettingsPage *m_settingsPage;
+};
+
+class CMakeSettingsPage : public Core::IOptionsPage
+{
+ Q_OBJECT
+public:
+ CMakeSettingsPage();
+ virtual ~CMakeSettingsPage();
+ virtual QString name() const;
+ virtual QString category() const;
+ virtual QString trCategory() const;
+
+ virtual QWidget *createPage(QWidget *parent);
+ virtual void apply();
+ virtual void finish();
+
+ QString cmakeExecutable() const;
+ void askUserForCMakeExecutable();
+private:
+ void updateCachedInformation() const;
+ void saveSettings() const;
+ QString findCmakeExecutable() const;
+ mutable QString m_cmakeExecutable;
+ mutable QString m_version;
+ mutable bool m_supportsQtCreator;
+ Core::Utils::PathChooser *m_pathchooser;
};
} // namespace Internal
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
index 74f69fea4ab..688d16b0a97 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro
@@ -18,3 +18,4 @@ SOURCES = cmakeproject.cpp \
makestep.cpp \
cmakerunconfiguration.cpp
RESOURCES += cmakeproject.qrc
+FORMS += cmakesettingspage.ui
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
index 29ad08ec5f1..4c16e0d997b 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp
@@ -59,7 +59,9 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
Core::ICore *core = Core::ICore::instance();
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":cmakeproject/CMakeProject.mimetypes.xml"), errorMessage))
return false;
- addAutoReleasedObject(new CMakeManager());
+ CMakeSettingsPage *cmp = new CMakeSettingsPage();
+ addAutoReleasedObject(cmp);
+ addAutoReleasedObject(new CMakeManager(cmp));
addAutoReleasedObject(new CMakeBuildStepFactory());
addAutoReleasedObject(new MakeBuildStepFactory());
addAutoReleasedObject(new CMakeRunConfigurationFactory());
diff --git a/src/plugins/projectexplorer/environment.cpp b/src/plugins/projectexplorer/environment.cpp
index 7a767d75b2e..38f35af9727 100644
--- a/src/plugins/projectexplorer/environment.cpp
+++ b/src/plugins/projectexplorer/environment.cpp
@@ -183,10 +183,6 @@ void Environment::clear()
m_values.clear();
}
-// currently it returns the string that was passed in, except
-// under windows and if the executable does not end in .exe
-// then it returns executable appended with .exe
-// that is clearly wrong
QString Environment::searchInPath(QString executable)
{
// qDebug()<<"looking for "<<executable<< "in PATH: "<<m_values.value("PATH");