summaryrefslogtreecommitdiffstats
path: root/Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx
diff options
context:
space:
mode:
authorCarsten Rudolph <18394207+crud89@users.noreply.github.com>2022-01-22 09:12:25 (GMT)
committerBrad King <brad.king@kitware.com>2022-01-22 11:35:41 (GMT)
commit9aa7831f05e924830848822aecdb43aa7261bc11 (patch)
tree8764b548493b8ce44b29310cae62d53ef314649b /Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx
parentb2f8f0bb87b3b49a39d1db4333bffc5405166245 (diff)
downloadCMake-9aa7831f05e924830848822aecdb43aa7261bc11.zip
CMake-9aa7831f05e924830848822aecdb43aa7261bc11.tar.gz
CMake-9aa7831f05e924830848822aecdb43aa7261bc11.tar.bz2
Presets: add resolve packages setting to build presets.
Diffstat (limited to 'Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx')
-rw-r--r--Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx35
1 files changed, 34 insertions, 1 deletions
diff --git a/Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx b/Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx
index ef605d1..eefe2fe 100644
--- a/Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx
+++ b/Source/cmCMakePresetsGraphReadJSONBuildPresets.cxx
@@ -12,6 +12,7 @@
#include <cm3p/json/value.h>
+#include "cmBuildOptions.h"
#include "cmCMakePresetsGraph.h"
#include "cmCMakePresetsGraphInternal.h"
#include "cmJSONHelpers.h"
@@ -20,6 +21,37 @@ namespace {
using ReadFileResult = cmCMakePresetsGraph::ReadFileResult;
using BuildPreset = cmCMakePresetsGraph::BuildPreset;
+ReadFileResult PackageResolveModeHelper(cm::optional<PackageResolveMode>& out,
+ const Json::Value* value)
+{
+ if (!value) {
+ out = cm::nullopt;
+ return ReadFileResult::READ_OK;
+ }
+
+ if (!value->isString()) {
+ return ReadFileResult::INVALID_PRESET;
+ }
+
+ if (value->asString() == "on") {
+ out = PackageResolveMode::Force;
+ } else if (value->asString() == "off") {
+ out = PackageResolveMode::Disable;
+ } else if (value->asString() == "only") {
+ out = PackageResolveMode::OnlyResolve;
+ } else {
+ return ReadFileResult::INVALID_PRESET;
+ }
+
+ return ReadFileResult::READ_OK;
+}
+
+std::function<ReadFileResult(BuildPreset&, const Json::Value*)> const
+ ResolvePackageReferencesHelper =
+ [](BuildPreset& out, const Json::Value* value) -> ReadFileResult {
+ return PackageResolveModeHelper(out.ResolvePackageReferences, value);
+};
+
auto const BuildPresetHelper =
cmJSONObjectHelper<BuildPreset, ReadFileResult>(
ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false)
@@ -59,7 +91,8 @@ auto const BuildPresetHelper =
.Bind("nativeToolOptions"_s, &BuildPreset::NativeToolOptions,
cmCMakePresetsGraphInternal::PresetVectorStringHelper, false)
.Bind("condition"_s, &BuildPreset::ConditionEvaluator,
- cmCMakePresetsGraphInternal::PresetConditionHelper, false);
+ cmCMakePresetsGraphInternal::PresetConditionHelper, false)
+ .Bind("resolvePackageReferences"_s, ResolvePackageReferencesHelper, false);
}
namespace cmCMakePresetsGraphInternal {