forked from qt-creator/qt-creator
CMakePM: Fix duplicated CMake presets kits
QTC_KIT_DEFAULT_CONFIG_HASH was introduced in order to match the previous CMake presets kits. This would hash the Qt and the C/C++ compiler paths. Unfortunately on Linux CMake would pick "cc" and "c++" by default, whilst Qt Creator uses "gcc" and "g++". The compilers would match from the Qt Creator point of view, but the hash values would be different. On mac there is a similar issue with compiler launchers. This patchset fixes this by removing the hash and fixes also the issue of allowing broken CMake presets kits (without any compilers), which were the reason for introducing the hash key in the first place. Fixes: QTCREATORBUG-29075 Change-Id: Id8dc081febba7bc7023c98055afc6ebfcdc55542 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -38,7 +38,6 @@
|
||||
#include <utils/variablechooser.h>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QCryptographicHash>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QGridLayout>
|
||||
@@ -874,7 +873,6 @@ const char CMAKE_CXX_TOOLCHAIN_KEY[] = "CMAKE_CXX_COMPILER";
|
||||
const char CMAKE_QMAKE_KEY[] = "QT_QMAKE_EXECUTABLE";
|
||||
const char CMAKE_PREFIX_PATH_KEY[] = "CMAKE_PREFIX_PATH";
|
||||
const char QTC_CMAKE_PRESET_KEY[] = "QTC_CMAKE_PRESET";
|
||||
const char QTC_KIT_DEFAULT_CONFIG_HASH[] = "QTC_KIT_DEFAULT_CONFIG_HASH";
|
||||
|
||||
class CMakeConfigurationKitAspectWidget final : public KitAspectWidget
|
||||
{
|
||||
@@ -1135,51 +1133,6 @@ CMakeConfigItem CMakeConfigurationKitAspect::cmakePresetConfigItem(const Project
|
||||
});
|
||||
}
|
||||
|
||||
void CMakeConfigurationKitAspect::setKitDefaultConfigHash(ProjectExplorer::Kit *k)
|
||||
{
|
||||
const CMakeConfig defaultConfigExpanded
|
||||
= Utils::transform(defaultConfiguration(k).toList(), [k](const CMakeConfigItem &item) {
|
||||
CMakeConfigItem expanded(item);
|
||||
expanded.value = item.expandedValue(k).toUtf8();
|
||||
return expanded;
|
||||
});
|
||||
const CMakeTool *const tool = CMakeKitAspect::cmakeTool(k);
|
||||
const QByteArray kitHash = computeDefaultConfigHash(defaultConfigExpanded,
|
||||
tool ? tool->cmakeExecutable()
|
||||
: FilePath());
|
||||
|
||||
CMakeConfig config = configuration(k);
|
||||
config.append(CMakeConfigItem(QTC_KIT_DEFAULT_CONFIG_HASH, CMakeConfigItem::INTERNAL, kitHash));
|
||||
|
||||
setConfiguration(k, config);
|
||||
}
|
||||
|
||||
CMakeConfigItem CMakeConfigurationKitAspect::kitDefaultConfigHashItem(const ProjectExplorer::Kit *k)
|
||||
{
|
||||
const CMakeConfig config = configuration(k);
|
||||
return Utils::findOrDefault(config, [](const CMakeConfigItem &item) {
|
||||
return item.key == QTC_KIT_DEFAULT_CONFIG_HASH;
|
||||
});
|
||||
}
|
||||
|
||||
QByteArray CMakeConfigurationKitAspect::computeDefaultConfigHash(const CMakeConfig &config,
|
||||
const FilePath &cmakeBinary)
|
||||
{
|
||||
const CMakeConfig defaultConfig = defaultConfiguration(nullptr);
|
||||
const QByteArray configValues = std::accumulate(defaultConfig.begin(),
|
||||
defaultConfig.end(),
|
||||
QByteArray(),
|
||||
[config](QByteArray &sum,
|
||||
const CMakeConfigItem &item) {
|
||||
return sum += config.valueOf(item.key);
|
||||
});
|
||||
return QCryptographicHash::hash(cmakeBinary.caseSensitivity() == Qt::CaseInsensitive
|
||||
? configValues.toLower()
|
||||
: configValues,
|
||||
QCryptographicHash::Md5)
|
||||
.toHex();
|
||||
}
|
||||
|
||||
QVariant CMakeConfigurationKitAspect::defaultValue(const Kit *k) const
|
||||
{
|
||||
// FIXME: Convert preload scripts
|
||||
|
||||
Reference in New Issue
Block a user