CMakePM: Add support for configure CMake presets

This patchset will add support for version 1 of the CMakePresets
feature that has been implemented in CMake 3.19

https://cmake.org/cmake/help/v3.19/manual/cmake-presets.7.html

The tests/manual/cmakepresets contains a manual test example for this
feature.

Task-number: QTCREATORBUG-24555
Change-Id: I93aba1ab4f090613d0b21d970b5b651d12c922af
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2022-05-30 19:04:54 +02:00
parent 4726b0da2d
commit 2ab1e76ca9
19 changed files with 1255 additions and 12 deletions

View File

@@ -0,0 +1,91 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
#include <utils/filepath.h>
#include "cmakeconfigitem.h"
#include <QHash>
#include <QString>
#include <QVersionNumber>
namespace CMakeProjectManager {
namespace Internal {
namespace PresetsDetails {
class ValueStrategyPair {
public:
std::optional<QString> value;
enum class Strategy : bool { set, external };
std::optional<Strategy> strategy;
};
class Warnings {
public:
std::optional<bool> dev;
std::optional<bool> deprecated;
std::optional<bool> uninitialized = false;
std::optional<bool> unusedCli = true;
std::optional<bool> systemVars = false;
};
class Errors {
public:
std::optional<bool> dev;
std::optional<bool> deprecated;
};
class Debug {
public:
std::optional<bool> output = false;
std::optional<bool> tryCompile = false;
std::optional<bool> find = false;
};
class ConfigurePreset {
public:
void inheritFrom(const ConfigurePreset &other);
QString name;
std::optional<bool> hidden = false;
std::optional<QStringList> inherits;
std::optional<QHash<QString, QString>> vendor;
std::optional<QString> displayName;
std::optional<QString> description;
std::optional<QString> generator;
std::optional<ValueStrategyPair> architecture;
std::optional<ValueStrategyPair> toolset;
std::optional<QString> binaryDir;
std::optional<QString> cmakeExecutable;
std::optional<CMakeConfig> cacheVariables;
std::optional<QHash<QString, QString>> environment;
std::optional<Warnings> warnings;
std::optional<Errors> errors;
std::optional<Debug> debug;
};
} // namespace PresetsDetails
class PresetsData
{
public:
int version = 0;
QVersionNumber cmakeMinimimRequired;
QHash<QString, QString> vendor;
std::vector<PresetsDetails::ConfigurePreset> configurePresets;
};
class PresetsParser
{
PresetsData m_presetsData;
public:
bool parse(Utils::FilePath const &jsonFile, QString &errorMessage, int &errorLine);
const PresetsData &presetsData() const;
};
} // namespace Internal
} // namespace CMakeProjectManager