mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-26 04:09:35 +03:00
presets: Detail conflicting diagnostic settings
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include <cm/memory>
|
||||
#include <cm/string_view>
|
||||
|
||||
#include "cmsys/RegularExpression.hxx"
|
||||
|
||||
@@ -949,6 +950,13 @@ bool cmCMakePresetsGraph::ConfigurePreset::VisitPresetAfterInherit(
|
||||
auto const ei = preset.Errors.find(w.first);
|
||||
if (ei != preset.Errors.end()) {
|
||||
if (w.second == false && ei->second == true) {
|
||||
cm::string_view const diagnostic =
|
||||
version < 12 && w.first == cmDiagnostics::CMD_AUTHOR
|
||||
? cm::string_view{ "dev" }
|
||||
: cmCMakePresetsGraphInternal::GetDiagnosticJSONName(w.first);
|
||||
this->ErrorDetail = cmStrCat("\"errors.", diagnostic,
|
||||
"\" is enabled while \"warnings.",
|
||||
diagnostic, "\" is disabled");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <cm/optional>
|
||||
#include <cm/string_view>
|
||||
|
||||
#include <cm3p/json/value.h>
|
||||
|
||||
@@ -306,6 +307,8 @@ bool WorkflowPresetsHelper(
|
||||
std::vector<cmCMakePresetsGraph::WorkflowPreset>& out,
|
||||
Json::Value const* value, cmJSONState* state);
|
||||
|
||||
cm::string_view GetDiagnosticJSONName(cmDiagnosticCategory category);
|
||||
|
||||
cmJSONHelper<std::nullptr_t> VendorHelper(ErrorGenerator const& error);
|
||||
|
||||
bool PresetConditionHelper(
|
||||
|
||||
@@ -233,18 +233,6 @@ cm::string_view GetJSONName()
|
||||
return storage;
|
||||
}
|
||||
|
||||
cm::string_view GetJSONName(cmDiagnosticCategory category)
|
||||
{
|
||||
static cm::string_view const names[] = {
|
||||
"none"_s, // CMD_NONE
|
||||
#define DIAGNOSTIC_JSON_NAME(C) GetJSONName<cmDiagnostics::C>(),
|
||||
CM_FOR_EACH_DIAGNOSTIC_CATEGORY(DIAGNOSTIC_JSON_NAME)
|
||||
#undef DIAGNOSTIC_JSON_NAME
|
||||
};
|
||||
assert(category > 0 && category < cmDiagnostics::CategoryCount);
|
||||
return names[category];
|
||||
}
|
||||
|
||||
auto const PresetDiagnosticMapHelper =
|
||||
cmCMakePresetsGraphInternal::PresetMapToBoolHelper<cmDiagnosticCategory>;
|
||||
|
||||
@@ -341,6 +329,18 @@ auto const ConfigurePresetHelper =
|
||||
}
|
||||
|
||||
namespace cmCMakePresetsGraphInternal {
|
||||
cm::string_view GetDiagnosticJSONName(cmDiagnosticCategory category)
|
||||
{
|
||||
static cm::string_view const names[] = {
|
||||
"none"_s, // CMD_NONE
|
||||
#define DIAGNOSTIC_JSON_NAME(C) GetJSONName<cmDiagnostics::C>(),
|
||||
CM_FOR_EACH_DIAGNOSTIC_CATEGORY(DIAGNOSTIC_JSON_NAME)
|
||||
#undef DIAGNOSTIC_JSON_NAME
|
||||
};
|
||||
assert(category > 0 && category < cmDiagnostics::CategoryCount);
|
||||
return names[category];
|
||||
}
|
||||
|
||||
bool ConfigurePresetsHelper(std::vector<ConfigurePreset>& out,
|
||||
Json::Value const* value, cmJSONState* state)
|
||||
{
|
||||
@@ -359,7 +359,7 @@ bool CheckDiagnostics(cmJSONState* state, int version,
|
||||
assert(i.first > 0 && i.first < cmDiagnostics::CategoryCount);
|
||||
int const minVersion = cmDiagnostics::CategoryInfo[i.first].PresetVersion;
|
||||
if (version < minVersion) {
|
||||
cm::string_view dn = GetJSONName(i.first);
|
||||
cm::string_view dn = GetDiagnosticJSONName(i.first);
|
||||
cmCMakePresetsErrors::DIAGNOSTIC_UNSUPPORTED(dn, group, minVersion,
|
||||
state);
|
||||
return false;
|
||||
@@ -395,7 +395,7 @@ bool CheckDiagnostics(cmJSONState* state, int version,
|
||||
|
||||
for (cmDiagnosticCategory c : unsupportedErrors) {
|
||||
if (cm::contains(preset.Errors, c)) {
|
||||
cm::string_view dn = GetJSONName(c);
|
||||
cm::string_view dn = GetDiagnosticJSONName(c);
|
||||
cmCMakePresetsErrors::DIAGNOSTIC_UNSUPPORTED(dn, "errors"_s, 12,
|
||||
state);
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,3 @@
|
||||
^CMake Error: Could not read presets from [^
|
||||
]*/Tests/RunCMake/CMakePresets/ErrorNoWarningAuthor:
|
||||
Invalid configure preset: "ErrorNoWarningAuthor": "errors.author" is enabled while "warnings.author" is disabled$
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"version": 12,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "ErrorNoWarningAuthor",
|
||||
"warnings": {
|
||||
"author": false
|
||||
},
|
||||
"errors": {
|
||||
"author": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
^CMake Error: Could not read presets from [^
|
||||
]*/Tests/RunCMake/CMakePresets/ErrorNoWarningDeprecated:
|
||||
Invalid configure preset: "ErrorNoWarningDeprecated"$
|
||||
Invalid configure preset: "ErrorNoWarningDeprecated": "errors.deprecated" is enabled while "warnings.deprecated" is disabled$
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
^CMake Error: Could not read presets from [^
|
||||
]*/Tests/RunCMake/CMakePresets/ErrorNoWarningDev:
|
||||
Invalid configure preset: "ErrorNoWarningDev"$
|
||||
Invalid configure preset: "ErrorNoWarningDev": "errors.dev" is enabled while "warnings.dev" is disabled$
|
||||
|
||||
@@ -189,6 +189,7 @@ run_cmake_presets(PackageInvalidInheritance)
|
||||
run_cmake_presets(TestInvalidInheritance)
|
||||
run_cmake_presets(PackageNoConfigurePreset)
|
||||
run_cmake_presets(ErrorNoWarningDev)
|
||||
run_cmake_presets(ErrorNoWarningAuthor)
|
||||
run_cmake_presets(ErrorNoWarningDeprecated)
|
||||
set(CMakePresets_SCHEMA_EXPECTED_RESULT 1)
|
||||
run_cmake_presets(InvalidArchitectureStrategy)
|
||||
|
||||
Reference in New Issue
Block a user