From a53308cde6d19c4fedd132f0aa4d3405b229122d Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 6 Apr 2020 15:21:10 +0200 Subject: [PATCH] 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 --- .../cmakeprojectmanager/cmakebuildconfiguration.cpp | 13 ++++++++++++- .../cmakeprojectmanager/cmakebuildsystem.cpp | 4 ---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp index 9c9d60cdba2..fdc02d0533a 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp @@ -70,7 +70,6 @@ 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(), @@ -157,6 +156,9 @@ 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(); @@ -164,6 +166,11 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Core::Id id) 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,6 +189,8 @@ QVariantMap CMakeBuildConfiguration::toMap() const bool CMakeBuildConfiguration::fromMap(const QVariantMap &map) { + QTC_CHECK(!m_buildSystem); + if (!BuildConfiguration::fromMap(map)) return false; @@ -192,6 +201,8 @@ bool CMakeBuildConfiguration::fromMap(const QVariantMap &map) setConfigurationForCMake(conf); + m_buildSystem = new CMakeBuildSystem(this); + return true; } diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index c346e368ef0..2f4d146fb3e 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -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()