forked from qt-creator/qt-creator
CMake: Keep cmake state in a temporary directory till first build
This avoids creating lots of build directories as the user types in something into the builddirectory line of the build settings. Change-Id: Ib08a0f65e08bce104e4baf9e19fb01730d2f5f08 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -222,6 +222,37 @@ bool CMakeBuildStep::init(QList<const BuildStep *> &earlierSteps)
|
||||
return AbstractProcessStep::init(earlierSteps);
|
||||
}
|
||||
|
||||
void CMakeBuildStep::run(QFutureInterface<bool> &fi)
|
||||
{
|
||||
// Make sure CMake state was written to disk before trying to build:
|
||||
CMakeBuildConfiguration *bc = cmakeBuildConfiguration();
|
||||
if (!bc)
|
||||
bc = qobject_cast<CMakeBuildConfiguration *>(target()->activeBuildConfiguration());
|
||||
QTC_ASSERT(bc, return);
|
||||
|
||||
if (bc->persistCMakeState()) {
|
||||
emit addOutput(tr("Persisting CMake state..."), BuildStep::MessageOutput);
|
||||
|
||||
m_runTrigger = connect(bc, &CMakeBuildConfiguration::dataAvailable,
|
||||
this, [this, &fi]() { runImpl(fi); });
|
||||
m_errorTrigger = connect(bc, &CMakeBuildConfiguration::errorOccured,
|
||||
this, [this, &fi]() {
|
||||
fi.reportResult(false);
|
||||
});
|
||||
} else {
|
||||
runImpl(fi);
|
||||
}
|
||||
}
|
||||
|
||||
void CMakeBuildStep::runImpl(QFutureInterface<bool> &fi)
|
||||
{
|
||||
// Do the actual build:
|
||||
disconnect(m_runTrigger);
|
||||
disconnect(m_errorTrigger);
|
||||
|
||||
AbstractProcessStep::run(fi);
|
||||
}
|
||||
|
||||
BuildStepConfigWidget *CMakeBuildStep::createConfigWidget()
|
||||
{
|
||||
return new CMakeBuildStepConfigWidget(this);
|
||||
|
||||
Reference in New Issue
Block a user