Commit 560b0639 authored by dt's avatar dt

Add msvc support to cmake plugin. Depends on a cvs version of cmake.

The CodeBlocks - NMake Makefiles generator combination is only available
in the cvs version of cmake.
This has not been extensively tested at all.
parent 7d43990d
......@@ -27,6 +27,15 @@
**
**************************************************************************/
/// TODO
/// To check
/// a) with an old cmake
/// => should not show combobox always use mingw generator
/// b) with an new cmake
/// always show combo box, defaulting if there's already a existing build
#include "cmakeopenprojectwizard.h"
#include "cmakeprojectmanager.h"
......@@ -268,12 +277,15 @@ void CMakeRunPage::initWidgets()
m_argumentsLineEdit = new QLineEdit(this);
connect(m_argumentsLineEdit,SIGNAL(returnPressed()), this, SLOT(runCMake()));
m_generatorComboBox = new QComboBox(this);
m_generatorComboBox->addItems(QStringList() << tr("NMake Generator") << tr("MinGW Generator"));
m_runCMake = new QPushButton(this);
m_runCMake->setText(tr("Run CMake"));
connect(m_runCMake, SIGNAL(clicked()), this, SLOT(runCMake()));
QHBoxLayout *hbox = new QHBoxLayout;
hbox->addWidget(m_argumentsLineEdit);
hbox->addWidget(m_generatorComboBox);
hbox->addWidget(m_runCMake);
fl->addRow(tr("Arguments"), hbox);
......@@ -313,6 +325,33 @@ void CMakeRunPage::initializePage()
"Some projects require command line arguments to the "
"initial cmake call."));
}
if (m_cmakeWizard->cmakeManager()->hasCodeBlocksMsvcGenerator()) {
m_generatorComboBox->setVisible(true);
QString generator;
// Try to find out generator from CMakeCachhe file, if it exists
QFile fi(m_buildDirectory + "/CMakeCache.txt");
if (fi.exists()) {
// Cache exists, then read it...
if (fi.open(QIODevice::ReadOnly)) {
while (fi.canReadLine()) {
QString line = fi.readLine();
if (line.startsWith("CMAKE_GENERATOR:INTERNAL=")) {
int splitpos = line.indexOf('=');
if (splitpos != -1) {
generator = line.mid(splitpos).trimmed();
}
break;
}
}
}
}
if (!generator.isEmpty()) {
m_generatorComboBox->setCurrentIndex((generator == "NMake Makefiles" ? 0 : 1));
}
} else {
// No new enough cmake, simply hide the combo box
m_generatorComboBox->setVisible(false);
}
}
void CMakeRunPage::runCMake()
......@@ -321,7 +360,13 @@ void CMakeRunPage::runCMake()
m_argumentsLineEdit->setEnabled(false);
QStringList arguments = ProjectExplorer::Environment::parseCombinedArgString(m_argumentsLineEdit->text());
CMakeManager *cmakeManager = m_cmakeWizard->cmakeManager();
m_cmakeProcess = cmakeManager->createXmlFile(arguments, m_cmakeWizard->sourceDirectory(), m_buildDirectory, m_cmakeWizard->environment());
#ifdef Q_OS_WIN
const QString generator = m_generatorComboBox->currentIndex() == 0 ? QLatin1String("-GCodeBlocks - NMake Makefiles") : QLatin1String("-GCodeBlocks - MinGW Makefiles");
#else // Q_OS_WIN
const QString generator = QLatin1String("-GCodeBlocks - Unix Makefiles");
#endif
m_cmakeProcess = cmakeManager->createXmlFile(arguments, m_cmakeWizard->sourceDirectory(), m_buildDirectory, m_cmakeWizard->environment(), generator);
connect(m_cmakeProcess, SIGNAL(readyRead()), this, SLOT(cmakeReadyRead()));
connect(m_cmakeProcess, SIGNAL(finished(int)), this, SLOT(cmakeFinished()));
}
......
......@@ -34,6 +34,7 @@
#include <QtCore/QProcess>
#include <QtGui/QPushButton>
#include <QtGui/QComboBox>
#include <QtGui/QLineEdit>
#include <QtGui/QLabel>
#include <QtGui/QWizard>
......@@ -147,6 +148,7 @@ private:
QPushButton *m_runCMake;
QProcess *m_cmakeProcess;
QLineEdit *m_argumentsLineEdit;
QComboBox *m_generatorComboBox;
QLabel *m_descriptionLabel;
bool m_complete;
Mode m_mode;
......
......@@ -92,11 +92,16 @@ QString CMakeManager::cmakeExecutable() const
return m_settingsPage->cmakeExecutable();
}
bool CMakeManager::hasCodeBlocksMsvcGenerator() const
{
return m_settingsPage->hasCodeBlocksMsvcGenerator();
}
// TODO 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
// sounds like a plan
QProcess *CMakeManager::createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory, const ProjectExplorer::Environment &env)
QProcess *CMakeManager::createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory, const ProjectExplorer::Environment &env, const QString &generator)
{
// We create a cbp file, only if we didn't find a cbp file in the base directory
// Yet that can still override cbp files in subdirectories
......@@ -115,11 +120,6 @@ QProcess *CMakeManager::createXmlFile(const QStringList &arguments, const QStrin
cmake->setProcessChannelMode(QProcess::MergedChannels);
cmake->setEnvironment(env.toStringList());
#ifdef Q_OS_WIN
const QString generator = QLatin1String("-GCodeBlocks - MinGW Makefiles");
#else // Q_OS_WIN
const QString generator = QLatin1String("-GCodeBlocks - Unix Makefiles");
#endif // Q_OS_WIN
const QString srcdir = buildDirectory.exists(QLatin1String("CMakeCache.txt")) ? QString(QLatin1Char('.')) : sourceDirectory;
qDebug()<<cmakeExecutable()<<srcdir<<arguments<<generator;
cmake->start(cmakeExecutable(), QStringList() << srcdir << arguments << generator);
......@@ -185,6 +185,7 @@ void CMakeRunner::run(QFutureInterface<void> &fi)
m_mutex.lock();
m_supportsQtCreator = response.contains(QLatin1String("QtCreator"));
m_hasCodeBlocksMsvcGenerator = response.contains(QLatin1String("CodeBlocks - NMake Makefiles"));
m_version = versionRegexp.cap(1);
if (!(versionRegexp.capturedTexts().size() > 3))
m_version += QLatin1Char('.') + versionRegexp.cap(3);
......@@ -230,6 +231,15 @@ bool CMakeRunner::supportsQtCreator() const
return result;
}
bool CMakeRunner::hasCodeBlocksMsvcGenerator() const
{
waitForUpToDate();
m_mutex.lock();
bool result = m_hasCodeBlocksMsvcGenerator;
m_mutex.unlock();
return result;
}
void CMakeRunner::waitForUpToDate() const
{
m_future.waitForFinished();
......@@ -317,6 +327,12 @@ QString CMakeSettingsPage::cmakeExecutable() const
return m_cmakeRunner.executable();
}
bool CMakeSettingsPage::hasCodeBlocksMsvcGenerator() const
{
return m_cmakeRunner.hasCodeBlocksMsvcGenerator();
}
void CMakeSettingsPage::askUserForCMakeExecutable()
{
// TODO implement
......
......@@ -62,7 +62,9 @@ public:
QProcess* createXmlFile(const QStringList &arguments,
const QString &sourceDirectory,
const QDir &buildDirectory,
const ProjectExplorer::Environment &env);
const ProjectExplorer::Environment &env,
const QString &generator);
bool hasCodeBlocksMsvcGenerator() const;
static QString findCbpFile(const QDir &);
static QString findDumperLibrary(const ProjectExplorer::Environment &env);
......@@ -82,6 +84,7 @@ public:
QString executable() const;
QString version() const;
bool supportsQtCreator() const;
bool hasCodeBlocksMsvcGenerator() const;
private:
void run(QFutureInterface<void> &fi);
......@@ -89,6 +92,7 @@ private:
QString m_executable;
QString m_version;
bool m_supportsQtCreator;
bool m_hasCodeBlocksMsvcGenerator;
bool m_cacheUpToDate;
mutable QFuture<void> m_future;
mutable QMutex m_mutex;
......@@ -111,6 +115,7 @@ public:
QString cmakeExecutable() const;
void askUserForCMakeExecutable();
bool hasCodeBlocksMsvcGenerator() const;
private:
void updateCachedInformation() const;
void saveSettings() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment