forked from qt-creator/qt-creator
CMakePM: Add action to reload CMake Presets
The CMake presets will be reloaded. The preset kits will get the CMake configuration cleared (no more CMakeCache.txt) All the kits will be removed from the project, so that the Kit configuration wizard will be displayed at the end. If a normal Qt Kit was configured, the user will get the chance to import the existing configuration (the initial configuration will be lost though). Change-Id: Ieda83098d7716913d7870b67ab522705da4ed93b Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "cmakebuildconfiguration.h"
|
||||
#include "cmakekitinformation.h"
|
||||
#include "cmakeproject.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
#include "cmaketoolmanager.h"
|
||||
@@ -15,6 +16,7 @@
|
||||
#include <projectexplorer/buildinfo.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/toolchainmanager.h>
|
||||
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
@@ -92,9 +94,9 @@ static QString uniqueCMakeToolDisplayName(CMakeTool &tool)
|
||||
|
||||
// CMakeProjectImporter
|
||||
|
||||
CMakeProjectImporter::CMakeProjectImporter(const FilePath &path, const PresetsData &presetsData)
|
||||
CMakeProjectImporter::CMakeProjectImporter(const FilePath &path, const CMakeProject *project)
|
||||
: QtProjectImporter(path)
|
||||
, m_presetsData(presetsData)
|
||||
, m_project(project)
|
||||
, m_presetsTempDir("qtc-cmake-presets-XXXXXXXX")
|
||||
{
|
||||
useTemporaryKitAspect(CMakeKitAspect::id(),
|
||||
@@ -119,7 +121,7 @@ FilePaths CMakeProjectImporter::importCandidates()
|
||||
candidates << scanDirectory(shadowBuildDirectory.absolutePath(), QString());
|
||||
}
|
||||
|
||||
for (const auto &configPreset : m_presetsData.configurePresets) {
|
||||
for (const auto &configPreset : m_project->presetsData().configurePresets) {
|
||||
if (configPreset.hidden.value())
|
||||
continue;
|
||||
|
||||
@@ -152,6 +154,21 @@ FilePaths CMakeProjectImporter::importCandidates()
|
||||
return finalists;
|
||||
}
|
||||
|
||||
Target *CMakeProjectImporter::preferredTarget(const QList<Target *> &possibleTargets)
|
||||
{
|
||||
for (Kit *kit : m_project->oldPresetKits()) {
|
||||
const bool haveKit = Utils::contains(possibleTargets, [kit](const auto &target) {
|
||||
return target->kit() == kit;
|
||||
});
|
||||
|
||||
if (!haveKit)
|
||||
KitManager::deregisterKit(kit);
|
||||
}
|
||||
m_project->setOldPresetKits({});
|
||||
|
||||
return ProjectImporter::preferredTarget(possibleTargets);
|
||||
}
|
||||
|
||||
static CMakeConfig configurationFromPresetProbe(
|
||||
const FilePath &importPath,
|
||||
const FilePath &sourceDirectory,
|
||||
@@ -618,7 +635,7 @@ QList<void *> CMakeProjectImporter::examineDirectory(const FilePath &importPath,
|
||||
|
||||
const QString presetName = importPath.fileName();
|
||||
PresetsDetails::ConfigurePreset configurePreset
|
||||
= Utils::findOrDefault(m_presetsData.configurePresets,
|
||||
= Utils::findOrDefault(m_project->presetsData().configurePresets,
|
||||
[presetName](const PresetsDetails::ConfigurePreset &preset) {
|
||||
return preset.name == presetName;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user