Skip to content
Snippets Groups Projects
Commit 118de5c2 authored by dt's avatar dt Committed by Daniel Teske
Browse files

Add a toolchain combo box to the cmake run page

Selecting the toolchain is a configure time setting for cmake. So
that's the right place, except for us the debugger also depends
on the toolchain. Switching the debugger thus involves reconfiguring.

Also due to the cmake cache in most cases reconfiguring with a different
toolchain selected won't do anything.

Cmake and creator's concept of toolchains clash.

Task-Nr: QTCREATORBUG-4898

Change-Id: Ibf84029d7008046891750a91666d0e3e4711ec69
Reviewed-on: http://codereview.qt.nokia.com/477


Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent d211ef0e
No related branches found
No related tags found
No related merge requests found
...@@ -383,56 +383,62 @@ void CMakeRunPage::initializePage() ...@@ -383,56 +383,62 @@ void CMakeRunPage::initializePage()
} else if (m_mode == CMakeRunPage::WantToUpdate) { } else if (m_mode == CMakeRunPage::WantToUpdate) {
m_descriptionLabel->setText(tr("Refreshing cbp file in %1.").arg(m_buildDirectory)); m_descriptionLabel->setText(tr("Refreshing cbp file in %1.").arg(m_buildDirectory));
} }
if (m_cmakeWizard->cmakeManager()->hasCodeBlocksMsvcGenerator()) {
// Try to find out generator from CMakeCache file, if it exists
QString cachedGenerator; // Try figuring out generator and toolchain from CMakeCache.txt
QString cachedGenerator;
QFile fi(m_buildDirectory + "/CMakeCache.txt"); QString cmakeCxxCompiler;
if (fi.exists()) { QFile fi(m_buildDirectory + "/CMakeCache.txt");
// Cache exists, then read it... if (fi.exists()) {
if (fi.open(QIODevice::ReadOnly | QIODevice::Text)) { // Cache exists, then read it...
while (!fi.atEnd()) { if (fi.open(QIODevice::ReadOnly | QIODevice::Text)) {
QString line = fi.readLine(); while (!fi.atEnd()) {
if (line.startsWith("CMAKE_GENERATOR:INTERNAL=")) { QString line = fi.readLine();
int splitpos = line.indexOf('='); if (line.startsWith("CMAKE_GENERATOR:INTERNAL=")) {
if (splitpos != -1) { int splitpos = line.indexOf('=');
cachedGenerator = line.mid(splitpos + 1).trimmed(); if (splitpos != -1)
} cachedGenerator = line.mid(splitpos + 1).trimmed();
break; }
} if (line.startsWith("CMAKE_CXX_COMPILER:FILEPATH=")) {
int splitpos = line.indexOf("=");
if (splitpos != -1)
cmakeCxxCompiler = line.mid(splitpos +1).trimmed();
} }
if (!cachedGenerator.isEmpty() && !cmakeCxxCompiler.isEmpty())
break;
} }
} }
}
m_generatorComboBox->setVisible(true); // Build the list of generators/toolchains we want to offer
m_generatorComboBox->clear(); // todo restrict toolchains based on CMAKE_CXX_COMPILER ?
ProjectExplorer::Abi abi = ProjectExplorer::Abi::hostAbi(); Q_UNUSED(cmakeCxxCompiler);
abi = ProjectExplorer::Abi(abi.architecture(), abi.os(), ProjectExplorer::Abi::UnknownFlavor, m_generatorComboBox->clear();
abi.binaryFormat(), abi.wordWidth() == 32 ? 32 : 0); bool hasCodeBlocksGenerator = m_cmakeWizard->cmakeManager()->hasCodeBlocksMsvcGenerator();
QList<ProjectExplorer::ToolChain *> tcs = ProjectExplorer::Abi abi = ProjectExplorer::Abi::hostAbi();
ProjectExplorer::ToolChainManager::instance()->findToolChains(abi); abi = ProjectExplorer::Abi(abi.architecture(), abi.os(), ProjectExplorer::Abi::UnknownFlavor,
foreach (ProjectExplorer::ToolChain *tc, tcs) { abi.binaryFormat(), abi.wordWidth() == 32 ? 32 : 0);
ProjectExplorer::Abi targetAbi = tc->targetAbi(); QList<ProjectExplorer::ToolChain *> tcs =
QVariant tcVariant = qVariantFromValue(static_cast<void *>(tc)); ProjectExplorer::ToolChainManager::instance()->findToolChains(abi);
if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) {
if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2005Flavor foreach (ProjectExplorer::ToolChain *tc, tcs) {
|| targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2008Flavor ProjectExplorer::Abi targetAbi = tc->targetAbi();
|| targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2010Flavor) QVariant tcVariant = qVariantFromValue(static_cast<void *>(tc));
if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) {
if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2005Flavor
|| targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2008Flavor
|| targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2010Flavor) {
if (hasCodeBlocksGenerator && (cachedGenerator.isEmpty() || cachedGenerator == "NMake Makefiles"))
m_generatorComboBox->addItem(tr("NMake Generator (%1)").arg(tc->displayName()), tcVariant); m_generatorComboBox->addItem(tr("NMake Generator (%1)").arg(tc->displayName()), tcVariant);
else if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) } else if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) {
if (cachedGenerator.isEmpty() || cachedGenerator == "MinGW Makefiles")
m_generatorComboBox->addItem(tr("MinGW Generator (%1)").arg(tc->displayName()), tcVariant); m_generatorComboBox->addItem(tr("MinGW Generator (%1)").arg(tc->displayName()), tcVariant);
else
continue;
} }
} else {
// Non windows
if (cachedGenerator.isEmpty() || cachedGenerator == "Unix Makefiles")
m_generatorComboBox->addItem(tr("Unix Generator (%1)").arg(tc->displayName()), tcVariant);
} }
} else {
// No new enough cmake, simply hide the combo box
m_generatorComboBox->setVisible(false);
QList<ProjectExplorer::ToolChain *> tcs =
ProjectExplorer::ToolChainManager::instance()->findToolChains(ProjectExplorer::Abi::hostAbi());
if (tcs.isEmpty())
return;
m_cmakeWizard->setToolChain(tcs.at(0));
} }
} }
...@@ -441,15 +447,10 @@ void CMakeRunPage::runCMake() ...@@ -441,15 +447,10 @@ void CMakeRunPage::runCMake()
int index = m_generatorComboBox->currentIndex(); int index = m_generatorComboBox->currentIndex();
ProjectExplorer::ToolChain *tc = 0; ProjectExplorer::ToolChain *tc = 0;
if (index >= 0) { if (index >= 0)
tc = static_cast<ProjectExplorer::ToolChain *>(m_generatorComboBox->itemData(index).value<void *>()); tc = static_cast<ProjectExplorer::ToolChain *>(m_generatorComboBox->itemData(index).value<void *>());
if (!tc)
return; m_cmakeWizard->setToolChain(tc);
m_cmakeWizard->setToolChain(tc);
} else {
tc = m_cmakeWizard->toolChain();
}
Q_ASSERT(tc);
m_runCMake->setEnabled(false); m_runCMake->setEnabled(false);
m_argumentsLineEdit->setEnabled(false); m_argumentsLineEdit->setEnabled(false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment