Skip to content

Commit

Permalink
CMake: Fix cmake preloadCache file support
Browse files Browse the repository at this point in the history
* Make it work at all again for cmake configurations without a
  preloadCache file
* Fix the KitInformation to provide the getters/setters like all
  the other KitInformation do
* Use those setters consistently
* Remove useless conversion from QString to QByteArray and back

Change-Id: I8fc43b3531da2c04034c89b29915a29c331fe064
Reviewed-by: Cristian Adam <[email protected]>
Reviewed-by: Benjamin Zeller <[email protected]>
Reviewed-by: Tobias Hunger <[email protected]>
  • Loading branch information
hunger committed Oct 29, 2015
1 parent b811089 commit ca6144f
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ void CMakeRunPage::runCMake()
m_argumentsLineEdit->text(), m_cmakeWizard->sourceDirectory(),
m_buildDirectory, env,
QString::fromLatin1(generatorInfo.generatorArgument()),
QString::fromLatin1(generatorInfo.preLoadScriptFileArgument()));
generatorInfo.preLoadCacheFileArgument());
} else {
m_runCMake->setEnabled(true);
m_argumentsLineEdit->setEnabled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void CMakePreloadCacheKitConfigWidget::makeReadOnly()
void CMakePreloadCacheKitConfigWidget::refresh()
{
if (!m_ignoreChange)
m_lineEdit->setText(m_kit->value(CMakePreloadCacheKitInformation::id()).toString());
m_lineEdit->setText(CMakePreloadCacheKitInformation::preloadCacheFile(m_kit));
}

void CMakePreloadCacheKitConfigWidget::preloadFileWasChanged(const QString &text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,26 @@ void CMakePreloadCacheKitInformation::fix(Kit *k)

KitInformation::ItemList CMakePreloadCacheKitInformation::toUserOutput(const Kit *k) const
{
return ItemList()
<< qMakePair(tr("CMake Preload"), k->value(id()).toString());
return ItemList() << qMakePair(tr("CMake Preload"), k->value(id()).toString());
}

KitConfigWidget *CMakePreloadCacheKitInformation::createConfigWidget(Kit *k) const
{
return new Internal::CMakePreloadCacheKitConfigWidget(k, this);
}

void CMakePreloadCacheKitInformation::setPreloadCacheFile(Kit *k, const QString &preload)
{
if (!k)
return;
k->setValue(CMakePreloadCacheKitInformation::id(), preload);
}

QString CMakePreloadCacheKitInformation::preloadCacheFile(const Kit *k)
{
if (!k)
return QString();
return k->value(CMakePreloadCacheKitInformation::id()).toString();
}

} // namespace CMakeProjectManager
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ class CMAKE_EXPORT CMakePreloadCacheKitInformation : public ProjectExplorer::Kit
QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const override;
void setup(ProjectExplorer::Kit *k) override;
void fix(ProjectExplorer::Kit *k) override;
virtual ItemList toUserOutput(const ProjectExplorer::Kit *k) const override;
virtual ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const override;
ItemList toUserOutput(const ProjectExplorer::Kit *k) const override;
ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const override;

static void setPreloadCacheFile(ProjectExplorer::Kit *k, const QString &preload);
static QString preloadCacheFile(const ProjectExplorer::Kit *k);
};

} // namespace CMakeProjectManager
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ void CMakeManager::createXmlFile(Utils::QtcProcess *proc, const QString &executa
Utils::QtcProcess::addArg(&args, srcdir);
Utils::QtcProcess::addArgs(&args, arguments);
Utils::QtcProcess::addArg(&args, generator);
Utils::QtcProcess::addArg(&args, preloadCache);
if (!preloadCache.isEmpty())
Utils::QtcProcess::addArg(&args, preloadCache);
proc->setCommand(executable, args);
proc->start();
}
Expand Down
11 changes: 3 additions & 8 deletions src/plugins/cmakeprojectmanager/generatorinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,10 @@ QByteArray GeneratorInfo::generatorArgument() const
return QByteArray("-GCodeBlocks - ") + tmp;
}

QByteArray GeneratorInfo::preLoadScriptFileArgument() const
QString GeneratorInfo::preLoadCacheFileArgument() const
{
if (!m_kit)
return QByteArray();

QByteArray tmp = m_kit->value(CMakePreloadCacheKitInformation::id()).toByteArray();
if (tmp.isEmpty())
return tmp;
return QByteArray("-C") + tmp;
const QString tmp = CMakePreloadCacheKitInformation::preloadCacheFile(m_kit);
return tmp.isEmpty() ? QString() : QString::fromLatin1("-C") + tmp;
}

QString GeneratorInfo::displayName() const
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/cmakeprojectmanager/generatorinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class GeneratorInfo
QString displayName() const;
QByteArray generatorArgument() const;
QByteArray generator() const;
QByteArray preLoadScriptFileArgument() const;
QString preLoadCacheFileArgument() const;

private:
ProjectExplorer::Kit *m_kit;
Expand Down

0 comments on commit ca6144f

Please sign in to comment.