CMake: Make sure a CMakeBuildConfiguration always has a CMakeBuildSystem

For this to work, we need to make sure no parsing is triggered before
the project is fully set up. Otherwise it would be QTCREATORBUG-23816
again...

Change-Id: If81f4c6b9c82283abdaa8a635f93ebe0bcaf8159
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Tobias Hunger
2020-04-20 17:33:36 +02:00
parent 283763a3e2
commit 5bb5c7b904
3 changed files with 118 additions and 102 deletions

View File

@@ -63,6 +63,8 @@ const char CONFIGURATION_KEY[] = "CMake.Configuration";
CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Core::Id id)
: BuildConfiguration(target, id)
{
m_buildSystem = new CMakeBuildSystem(this);
setBuildDirectory(shadowBuildDirectory(project()->projectFilePath(),
target->kit(),
displayName(),
@@ -149,21 +151,12 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Core::Id id)
}
setConfigurationForCMake(config);
// Only do this after everything has been set up!
m_buildSystem = new CMakeBuildSystem(this);
});
const auto qmlDebuggingAspect = addAspect<QtSupport::QmlDebuggingAspect>();
qmlDebuggingAspect->setKit(target->kit());
connect(qmlDebuggingAspect, &QtSupport::QmlDebuggingAspect::changed,
this, &CMakeBuildConfiguration::configurationForCMakeChanged);
// m_buildSystem is still nullptr here since it the build directory to be available
// before it can get created.
//
// This means this needs to be done in the lambda for the setInitializer(...) call
// defined above as well as in fromMap!
}
CMakeBuildConfiguration::~CMakeBuildConfiguration()
@@ -182,8 +175,6 @@ QVariantMap CMakeBuildConfiguration::toMap() const
bool CMakeBuildConfiguration::fromMap(const QVariantMap &map)
{
QTC_CHECK(!m_buildSystem);
if (!BuildConfiguration::fromMap(map))
return false;
@@ -194,8 +185,6 @@ bool CMakeBuildConfiguration::fromMap(const QVariantMap &map)
setConfigurationForCMake(conf);
m_buildSystem = new CMakeBuildSystem(this);
return true;
}