CMake: Do not create .cmake directories in source dir

Only initialize the CMakeBuildSystem after the
CMakeBuildConfiguration has been fully set up. The "builddirectory"
was still pointing to the source directory, so creater configured
cmake in the source directory, leading to a useless directory being
left in the source tree that does not belong there.

Fixes: QTCREATORBUG-23816
Change-Id: I7c9b6ae1f8d999043e700cd9f2d56418c22f2abf
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Tobias Hunger
2020-04-06 15:21:10 +02:00
parent 35c5c09c38
commit a53308cde6
2 changed files with 12 additions and 5 deletions

View File

@@ -70,7 +70,6 @@ const char CONFIGURATION_KEY[] = "CMake.Configuration";
CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Core::Id id) CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Core::Id id)
: BuildConfiguration(target, id) : BuildConfiguration(target, id)
{ {
m_buildSystem = new CMakeBuildSystem(this);
setBuildDirectory(shadowBuildDirectory(project()->projectFilePath(), setBuildDirectory(shadowBuildDirectory(project()->projectFilePath(),
target->kit(), target->kit(),
displayName(), displayName(),
@@ -157,6 +156,9 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Core::Id id)
} }
setConfigurationForCMake(config); setConfigurationForCMake(config);
// Only do this after everything has been set up!
m_buildSystem = new CMakeBuildSystem(this);
}); });
const auto qmlDebuggingAspect = addAspect<QtSupport::QmlDebuggingAspect>(); const auto qmlDebuggingAspect = addAspect<QtSupport::QmlDebuggingAspect>();
@@ -164,6 +166,11 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Core::Id id)
connect(qmlDebuggingAspect, &QtSupport::QmlDebuggingAspect::changed, connect(qmlDebuggingAspect, &QtSupport::QmlDebuggingAspect::changed,
this, &CMakeBuildConfiguration::configurationForCMakeChanged); 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() CMakeBuildConfiguration::~CMakeBuildConfiguration()
@@ -182,6 +189,8 @@ QVariantMap CMakeBuildConfiguration::toMap() const
bool CMakeBuildConfiguration::fromMap(const QVariantMap &map) bool CMakeBuildConfiguration::fromMap(const QVariantMap &map)
{ {
QTC_CHECK(!m_buildSystem);
if (!BuildConfiguration::fromMap(map)) if (!BuildConfiguration::fromMap(map))
return false; return false;
@@ -192,6 +201,8 @@ bool CMakeBuildConfiguration::fromMap(const QVariantMap &map)
setConfigurationForCMake(conf); setConfigurationForCMake(conf);
m_buildSystem = new CMakeBuildSystem(this);
return true; return true;
} }

View File

@@ -214,10 +214,6 @@ CMakeBuildSystem::CMakeBuildSystem(CMakeBuildConfiguration *bc)
} }
} }
}); });
qCDebug(cmakeBuildSystemLog) << "Requesting parse due to initial CMake BuildSystem setup";
m_buildDirManager.setParametersAndRequestParse(BuildDirParameters(m_buildConfiguration),
BuildDirManager::REPARSE_CHECK_CONFIGURATION);
} }
CMakeBuildSystem::~CMakeBuildSystem() CMakeBuildSystem::~CMakeBuildSystem()