forked from qt-creator/qt-creator
CMakePM: Set CMakePM project settings via CMakePresets's vendor field
The field name is "qt.io/QtCreator/1.0":
```
"vendor": {
"qt.io/QtCreator/1.0": {
"AskBeforePresetsReload": false,
"AskReConfigureInitialParams": false,
"AutorunCMake": false,
"PackageManagerAutoSetup": false,
"ShowAdvancedOptionsByDefault": true,
"ShowSourceSubFolders": false,
"UseJunctionsForSourceAndBuildDirectories": true
}
}
```
Fixes: QTCREATORBUG-25972
Fixes: QTCREATORBUG-29559
Fixes: QTCREATORBUG-30385
Change-Id: Ifac0d10eebda85f8d97e7a1387325a555101ea6d
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -435,6 +435,30 @@ bool parseBuildPresets(const QJsonValue &jsonValue,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool parseVendor(const QJsonValue &jsonValue, std::optional<QVariantMap> &vendorSettings)
|
||||
{
|
||||
// The whole section is optional
|
||||
if (jsonValue.isUndefined())
|
||||
return true;
|
||||
if (!jsonValue.isObject())
|
||||
return false;
|
||||
|
||||
const QJsonObject object = jsonValue.toObject();
|
||||
const QJsonValue qtIo = object.value("qt.io/QtCreator/1.0");
|
||||
if (qtIo.isUndefined())
|
||||
return true;
|
||||
if (!qtIo.isObject())
|
||||
return false;
|
||||
|
||||
const QJsonObject qtIoObject = qtIo.toObject();
|
||||
vendorSettings = QVariantMap();
|
||||
for (const QString &settingKey : qtIoObject.keys()) {
|
||||
const QJsonValue settingValue = qtIoObject.value(settingKey);
|
||||
vendorSettings->insert(settingKey, settingValue.toVariant());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const PresetsData &PresetsParser::presetsData() const
|
||||
{
|
||||
return m_presetsData;
|
||||
@@ -502,6 +526,12 @@ bool PresetsParser::parse(const Utils::FilePath &jsonFile, QString &errorMessage
|
||||
return false;
|
||||
}
|
||||
|
||||
// optional
|
||||
if (!parseVendor(root.value("vendor"), m_presetsData.vendor)) {
|
||||
errorMessage = ::CMakeProjectManager::Tr::tr("Invalid \"vendor\" section in %1 file")
|
||||
.arg(jsonFile.fileName());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user