summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog/CMakeSetupDialog.cxx
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2008-05-15 23:21:01 (GMT)
committerClinton Stimpson <clinton@elemtech.com>2008-05-15 23:21:01 (GMT)
commitf8f4140b6ca1d7f1944514741f61aaf631b59115 (patch)
treeb5cb3b3b79515727c503194c0f639298a98826b1 /Source/QtDialog/CMakeSetupDialog.cxx
parent3e6decf31205ecfcbe837c0d0344f4597aa33369 (diff)
downloadCMake-f8f4140b6ca1d7f1944514741f61aaf631b59115.zip
CMake-f8f4140b6ca1d7f1944514741f61aaf631b59115.tar.gz
CMake-f8f4140b6ca1d7f1944514741f61aaf631b59115.tar.bz2
ENH: Add cross compiling support in the GUI in the same dialog that prompts for
the generator on the first configure. It either ask for a toolchain file or asks for all the information a toolchain file might contain. Also added option for setting non-default compilers if not cross compiling. Fixes #6849. Also a bit of code cleanup and re-organizing.
Diffstat (limited to 'Source/QtDialog/CMakeSetupDialog.cxx')
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx150
1 files changed, 89 insertions, 61 deletions
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 56ee7ac..3eda31d 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -36,6 +36,7 @@
#include "QCMake.h"
#include "QCMakeCacheView.h"
#include "AddCacheEntry.h"
+#include "CMakeFirstConfigure.h"
QCMakeThread::QCMakeThread(QObject* p)
: QThread(p), CMakeInstance(NULL)
@@ -60,7 +61,6 @@ void QCMakeThread::run()
CMakeSetupDialog::CMakeSetupDialog()
: ExitAfterGenerate(true), CacheModified(false), CurrentState(Interrupting)
{
- this->SuppressDevWarnings = false;
// create the GUI
QSettings settings;
settings.beginGroup("Settings/StartPath");
@@ -104,11 +104,9 @@ CMakeSetupDialog::CMakeSetupDialog()
this, SLOT(doInstallForCommandLine()));
#endif
QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options"));
- QAction* supressDevWarningsAction = OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)"));
- QObject::connect(supressDevWarningsAction, SIGNAL(triggered(bool)),
- this, SLOT(doSuppressDev()));
+ this->SuppressDevWarningsAction = OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)"));
+ this->SuppressDevWarningsAction->setCheckable(true);
- supressDevWarningsAction->setCheckable(true);
QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output"));
debugAction->setCheckable(true);
QObject::connect(debugAction, SIGNAL(toggled(bool)),
@@ -153,9 +151,9 @@ void CMakeSetupDialog::initialize()
{
// now the cmake worker thread is running, lets make our connections to it
QObject::connect(this->CMakeThread->cmakeInstance(),
- SIGNAL(propertiesChanged(const QCMakeCachePropertyList&)),
+ SIGNAL(propertiesChanged(const QCMakePropertyList&)),
this->CacheValues->cacheModel(),
- SLOT(setProperties(const QCMakeCachePropertyList&)));
+ SLOT(setProperties(const QCMakePropertyList&)));
QObject::connect(this->ConfigureButton, SIGNAL(clicked(bool)),
this, SLOT(doConfigure()));
@@ -220,6 +218,8 @@ void CMakeSetupDialog::initialize()
QObject::connect(this->AddEntry, SIGNAL(clicked(bool)),
this, SLOT(addCacheEntry()));
+ QObject::connect(this->SuppressDevWarningsAction, SIGNAL(triggered(bool)),
+ this->CMakeThread->cmakeInstance(), SLOT(setSuppressDevWarnings(bool)));
if(!this->SourceDirectory->text().isEmpty() ||
!this->BinaryDirectory->lineEdit()->text().isEmpty())
@@ -275,10 +275,10 @@ void CMakeSetupDialog::doConfigure()
dir.mkpath(".");
}
- // prompt for generator if it hasn't been set
+ // if no generator, prompt for it and other setup stuff
if(this->CMakeThread->cmakeInstance()->generator().isEmpty())
{
- if(!this->promptForGenerator())
+ if(!this->setupFirstConfigure())
{
return;
}
@@ -292,7 +292,7 @@ void CMakeSetupDialog::doConfigure()
this->CacheValues->selectionModel()->clear();
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
"setProperties", Qt::QueuedConnection,
- Q_ARG(QCMakeCachePropertyList,
+ Q_ARG(QCMakePropertyList,
this->CacheValues->cacheModel()->properties()));
QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
"configure", Qt::QueuedConnection);
@@ -329,13 +329,6 @@ void CMakeSetupDialog::finishGenerate(int err)
}
}
-void CMakeSetupDialog::doSuppressDev()
-{
- this->SuppressDevWarnings = !this->SuppressDevWarnings;
- this->CMakeThread->cmakeInstance()->
- SetSuppressDevWarnings(this->SuppressDevWarnings);
-}
-
void CMakeSetupDialog::doInstallForCommandLine()
{
QMacInstallDialog setupdialog(0);
@@ -542,41 +535,89 @@ void CMakeSetupDialog::setEnabledState(bool enabled)
this->RemoveEntry->setEnabled(false); // let selection re-enable it
}
-bool CMakeSetupDialog::promptForGenerator()
+bool CMakeSetupDialog::setupFirstConfigure()
{
- QSettings settings;
- settings.beginGroup("Settings/StartPath");
- QString lastGen = settings.value("LastGenerator").toString();
+ CMakeFirstConfigure dialog;
- QStringList gens = this->CMakeThread->cmakeInstance()->availableGenerators();
- QDialog dialog;
- dialog.setWindowTitle(tr("Choose Generator"));
- QLabel* lab = new QLabel(&dialog);
- lab->setText(tr("Please select what build system you want CMake to generate files for.\n"
- "You should select the tool that you will use to build the project.\n"
- "Press OK once you have made your selection."));
- QComboBox* combo = new QComboBox(&dialog);
- combo->addItems(gens);
- int idx = combo->findText(lastGen);
- if(idx != -1)
- {
- combo->setCurrentIndex(idx);
- }
- QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok |
- QDialogButtonBox::Cancel,
- Qt::Horizontal, &dialog);
- QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
- QObject::connect(btns, SIGNAL(rejected()), &dialog, SLOT(reject()));
+ // initialize dialog and restore saved settings
+
+ // add generators
+ dialog.setGenerators(this->CMakeThread->cmakeInstance()->availableGenerators());
+
+ // restore from settings
+ dialog.loadFromSettings();
- QVBoxLayout* l = new QVBoxLayout(&dialog);
- l->addWidget(lab);
- l->addWidget(combo);
- l->addWidget(btns);
if(dialog.exec() == QDialog::Accepted)
{
- lastGen = combo->currentText();
- settings.setValue("LastGenerator", lastGen);
- this->CMakeThread->cmakeInstance()->setGenerator(combo->currentText());
+ dialog.saveToSettings();
+ this->CMakeThread->cmakeInstance()->setGenerator(dialog.getGenerator());
+
+ QCMakeCacheModel* m = this->CacheValues->cacheModel();
+
+ if(dialog.compilerSetup())
+ {
+ QString fortranCompiler = dialog.getFortranCompiler();
+ if(!fortranCompiler.isEmpty())
+ {
+ m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER",
+ "Fortran compiler.", fortranCompiler, false);
+ }
+ QString cxxCompiler = dialog.getCXXCompiler();
+ if(!cxxCompiler.isEmpty())
+ {
+ m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER",
+ "CXX compiler.", cxxCompiler, false);
+ }
+
+ QString cCompiler = dialog.getCCompiler();
+ if(!cCompiler.isEmpty())
+ {
+ m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER",
+ "C compiler.", cCompiler, false);
+ }
+ }
+ else if(dialog.crossCompilerSetup())
+ {
+ QString toolchainFile = dialog.crossCompilerToolChainFile();
+ if(!toolchainFile.isEmpty())
+ {
+ m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_TOOLCHAIN_FILE",
+ "Cross Compile ToolChain File", toolchainFile, false);
+ }
+ else
+ {
+ QString fortranCompiler = dialog.getFortranCompiler();
+ if(!fortranCompiler.isEmpty())
+ {
+ m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER",
+ "Fortran compiler.", fortranCompiler, false);
+ }
+
+ QString mode = dialog.getCrossIncludeMode();
+ m->insertProperty(0, QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE",
+ "CMake Find Include Mode", mode, false);
+ mode = dialog.getCrossLibraryMode();
+ m->insertProperty(0, QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY",
+ "CMake Find Library Mode", mode, false);
+ mode = dialog.getCrossProgramMode();
+ m->insertProperty(0, QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM",
+ "CMake Find Program Mode", mode, false);
+
+ QString rootPath = dialog.getCrossRoot();
+ m->insertProperty(0, QCMakeProperty::PATH, "CMAKE_FIND_ROOT_PATH",
+ "CMake Find Root Path", rootPath, false);
+
+ QString systemName = dialog.getSystemName();
+ m->insertProperty(0, QCMakeProperty::STRING, "CMAKE_SYSTEM_NAME",
+ "CMake System Name", systemName, false);
+ QString cxxCompiler = dialog.getCXXCompiler();
+ m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER",
+ "CXX compiler.", cxxCompiler, false);
+ QString cCompiler = dialog.getCCompiler();
+ m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER",
+ "C compiler.", cCompiler, false);
+ }
+ }
return true;
}
@@ -856,20 +897,7 @@ void CMakeSetupDialog::addCacheEntry()
if(QDialog::Accepted == dialog.exec())
{
QCMakeCacheModel* m = this->CacheValues->cacheModel();
- m->insertRows(0, 1, QModelIndex());
- m->setData(m->index(0, 0), w->type(), QCMakeCacheModel::TypeRole);
- m->setData(m->index(0, 0), w->name(), Qt::DisplayRole);
- m->setData(m->index(0, 0), w->description(), QCMakeCacheModel::HelpRole);
- m->setData(m->index(0, 0), 0, QCMakeCacheModel::AdvancedRole);
- if(w->type() == QCMakeCacheProperty::BOOL)
- {
- m->setData(m->index(0, 1), w->value().toBool() ?
- Qt::Checked : Qt::Unchecked, Qt::CheckStateRole);
- }
- else
- {
- m->setData(m->index(0, 1), w->value(), Qt::DisplayRole);
- }
+ m->insertProperty(0, w->type(), w->name(), w->description(), w->value(), false);
}
}