CMake: Add 'Profile' configuration

Get rid of the hardcoded QML Debugging for Debug & RelWithDebInfo from
the project template, because RelWithDebInfo is actually a good
configuration for doing releases (we use it for Qt Creator), and
enabling QML debugging for releases is a bad idea.

Instead enable QML Debugging in Qt Creator for the Debug configuration,
and add a 'Profile' configuration that is 'RelWithDebInfo + QML
Debugging'.

When importing a build, we only set the "QML debugging" option of the
build configuration, if it is enabled in the imported build, even if it
uses CMAKE_BUILD_TYPE=Debug .

One drawback: When not importing a build, but just setting the build
directory of a "Profile" or "Debug" configuration to an existing build,
Qt Creator asks if it should apply "-DCMAKE_CXX_FLAGS=-DQT_QML_DEBUG".
The user can choose not to, but then is asked the next time again, and
it is not obvious that the "QML debugging" option is responsible for
this.

That is somewhat orthogonal to this change though: Even without this
change, if the user changes the QML debugging option from "Leave at
Default" to "Enable", the same happens, and it is also not clear to the
user how to get rid of it. The user might not even have realized that
they changed the option (e.g. on platforms where the mouse wheel cycles
combo box values).

I think the correct solution is to 1. make clearer where the CMake flags
came from in that dialog, 2. allow the user to cancel a build from that
dialog, 3. allow the user to discard these changes (by changing the
setting) from that dialog. But that is for another patch.

Amends 3300182d40
Amends 77fed0b0fd

Change-Id: I95de59473b67c5afd6a53ea7f49838dbaef770d4
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Eike Ziller
2022-05-18 10:40:31 +02:00
parent f9433c79b7
commit 2577ce8ba1
6 changed files with 67 additions and 31 deletions

View File

@@ -63,6 +63,7 @@ struct DirectoryData
QByteArray cmakeBuildType;
FilePath buildDirectory;
FilePath cmakeHomeDirectory;
bool hasQmlDebugging = false;
// Kit Stuff
FilePath cmakeBinary;
@@ -336,6 +337,14 @@ 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->buildDirectory = importPath;
data->cmakeBuildType = buildType;
@@ -437,13 +446,22 @@ const QList<BuildInfo> CMakeProjectImporter::buildInfoList(void *directoryData)
auto data = static_cast<const DirectoryData *>(directoryData);
// create info:
BuildInfo info = CMakeBuildConfigurationFactory::createBuildInfo(
CMakeBuildConfigurationFactory::buildTypeFromByteArray(data->cmakeBuildType));
CMakeBuildConfigurationFactory::BuildType buildType
= CMakeBuildConfigurationFactory::buildTypeFromByteArray(data->cmakeBuildType);
// RelWithDebInfo + QML Debugging = Profile
if (buildType == CMakeBuildConfigurationFactory::BuildTypeRelWithDebInfo
&& data->hasQmlDebugging)
buildType = CMakeBuildConfigurationFactory::BuildTypeProfile;
BuildInfo info = CMakeBuildConfigurationFactory::createBuildInfo(buildType);
info.buildDirectory = data->buildDirectory;
info.displayName = info.typeName;
QVariantMap config;
QVariantMap config = info.extraInfo.toMap(); // new empty, or existing one from createBuildInfo
config.insert(Constants::CMAKE_HOME_DIR, data->cmakeHomeDirectory.toString());
// Potentially overwrite the default QML Debugging settings for the build type as set by
// createBuildInfo, in case we are importing a "Debug" CMake configuration without QML Debugging
config.insert(Constants::QML_DEBUG_SETTING,
data->hasQmlDebugging ? TriState::Enabled.toVariant()
: TriState::Default.toVariant());
info.extraInfo = config;
qCDebug(cmInputLog) << "BuildInfo configured.";