CMake: Make QML debugging state reflect build system state

After parsing the CMake response, we make the configuration variables
table reflect the actual configuration in the build directory. It is one
of our "promises" that we do not break an existing build configuration,
to avoid unexpected rebuilds.

This was not quite true for the "QML debugging and profiling" setting.
When that setting and the actual build directory disagreed, the user
would get a dialog asking for running CMake with additional parameters,
and when running CMake via the button in projects mode or the menu, it
would just change these configuration parameters, potentially leading to
an unexpected complete rebuild of the application.

So, after parsing check if the actual CMake configuration matches our
QML debugging setting, and if not, change the setting to "Leave at
Default", to ensure that we don't mess with the build.

Fix the "Run CMake" button state (in the "Current Configuration") when
changing the QML debugging option, which should become bold, if the
CMake parameters change.

Amends 2577ce8ba1 and fixes the drawback
mentioned there, i.e. setting the build directory of a "Debug" build
configuration to an existing build directory with QML debugging
disabled, will now simply set the QML debugging option to "Leave at
Default" instead of forcing it to "Enabled".

Change-Id: Ie6d4875d59319687d94e44e459ca76038e5813c0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Eike Ziller
2022-06-07 10:18:34 +02:00
parent 948f0070fa
commit a760d5ad81
3 changed files with 24 additions and 9 deletions

View File

@@ -379,7 +379,16 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
}
connect(m_buildSystem, &BuildSystem::parsingFinished, this, [this] {
m_configModel->setConfiguration(m_buildSystem->configurationFromCMake());
const CMakeConfig config = m_buildSystem->configurationFromCMake();
auto qmlDebugAspect = m_buildSystem->buildConfiguration()
->aspect<QtSupport::QmlDebuggingAspect>();
const TriState qmlDebugSetting = qmlDebugAspect->value();
bool qmlDebugConfig = CMakeBuildConfiguration::hasQmlDebugging(config);
if ((qmlDebugSetting == TriState::Enabled && !qmlDebugConfig)
|| (qmlDebugSetting == TriState::Disabled && qmlDebugConfig)) {
qmlDebugAspect->setValue(TriState::Default);
}
m_configModel->setConfiguration(config);
m_configModel->setInitialParametersConfiguration(
m_buildSystem->initialCMakeConfiguration());
m_buildSystem->filterConfigArgumentsFromAdditionalCMakeArguments();
@@ -738,7 +747,8 @@ void CMakeBuildSettingsWidget::updateButtonState()
} else {
m_reconfigureButton->setText(tr("Run CMake"));
}
reconfigureButtonFont.setBold(m_configModel->hasChanges(isInitial));
reconfigureButtonFont.setBold(isInitial ? m_configModel->hasChanges(isInitial)
: !configChanges.isEmpty());
}
m_reconfigureButton->setFont(reconfigureButtonFont);
@@ -1388,6 +1398,16 @@ bool CMakeBuildConfiguration::isIos(const Kit *k)
|| deviceType == Ios::Constants::IOS_SIMULATOR_TYPE;
}
bool CMakeBuildConfiguration::hasQmlDebugging(const CMakeConfig &config)
{
// Determine QML debugging flags. This must match what we do in
// CMakeBuildSettingsWidget::getQmlDebugCxxFlags()
// such that in doubt we leave the QML Debugging setting at "Leave at default"
const QString cxxFlagsInit = config.stringValueOf("CMAKE_CXX_FLAGS_INIT");
const QString cxxFlags = config.stringValueOf("CMAKE_CXX_FLAGS");
return cxxFlagsInit.contains("-DQT_QML_DEBUG") && cxxFlags.contains("-DQT_QML_DEBUG");
}
void CMakeBuildConfiguration::buildTarget(const QString &buildTarget)
{
auto cmBs = qobject_cast<CMakeBuildStep *>(findOrDefault(

View File

@@ -55,6 +55,7 @@ public:
shadowBuildDirectory(const Utils::FilePath &projectFilePath, const ProjectExplorer::Kit *k,
const QString &bcName, BuildConfiguration::BuildType buildType);
static bool isIos(const ProjectExplorer::Kit *k);
static bool hasQmlDebugging(const CMakeConfig &config);
// Context menu action:
void buildTarget(const QString &buildTarget);

View File

@@ -337,13 +337,7 @@ QList<void *> CMakeProjectImporter::examineDirectory(const FilePath &importPath,
canonicalProjectDirectory.toUserOutput());
}
// Determine QML debugging flags. This must match what we do in
// CMakeBuildSettingsWidget::getQmlDebugCxxFlags()
// such that in doubt we leave the QML Debugging setting at "Leave at default"
const QString cxxFlagsInit = config.stringValueOf("CMAKE_CXX_FLAGS_INIT");
const QString cxxFlags = config.stringValueOf("CMAKE_CXX_FLAGS");
data->hasQmlDebugging = cxxFlagsInit.contains("-DQT_QML_DEBUG")
&& cxxFlags.contains("-DQT_QML_DEBUG");
data->hasQmlDebugging = CMakeBuildConfiguration::hasQmlDebugging(config);
data->buildDirectory = importPath;
data->cmakeBuildType = buildType;