summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-10-22 15:04:13 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-10-22 15:04:19 (GMT)
commit6abe14d2263476755364ef5017cc6b25b42a9ed5 (patch)
tree66189aa62b69d47ce196692dfa82b1f5ff8b7c25 /Source
parent504aadf414d6c53c9eeb0c74b1a4b5438e0e5c3d (diff)
parent920d18004731c97a828a937e2074b6882ffeb20d (diff)
downloadCMake-6abe14d2263476755364ef5017cc6b25b42a9ed5.zip
CMake-6abe14d2263476755364ef5017cc6b25b42a9ed5.tar.gz
CMake-6abe14d2263476755364ef5017cc6b25b42a9ed5.tar.bz2
Merge topic 'cmake-presets-boolean-cache'
920d180047 CMakePresets.json: Allow boolean for cache variable value Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5398
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCMakePresetsFile.cxx24
1 files changed, 23 insertions, 1 deletions
diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx
index 90a0faa..456094f 100644
--- a/Source/cmCMakePresetsFile.cxx
+++ b/Source/cmCMakePresetsFile.cxx
@@ -77,15 +77,37 @@ auto const RootVersionHelper =
auto const VariableStringHelper = cmJSONStringHelper<ReadFileResult>(
ReadFileResult::READ_OK, ReadFileResult::INVALID_VARIABLE);
+ReadFileResult VariableValueHelper(std::string& out, const Json::Value* value)
+{
+ if (!value) {
+ out.clear();
+ return ReadFileResult::READ_OK;
+ }
+
+ if (value->isBool()) {
+ out = value->asBool() ? "TRUE" : "FALSE";
+ return ReadFileResult::READ_OK;
+ }
+
+ return VariableStringHelper(out, value);
+}
+
auto const VariableObjectHelper =
cmJSONObjectHelper<CacheVariable, ReadFileResult>(
ReadFileResult::READ_OK, ReadFileResult::INVALID_VARIABLE, false)
.Bind("type"_s, &CacheVariable::Type, VariableStringHelper, false)
- .Bind("value"_s, &CacheVariable::Value, VariableStringHelper);
+ .Bind("value"_s, &CacheVariable::Value, VariableValueHelper);
ReadFileResult VariableHelper(cm::optional<CacheVariable>& out,
const Json::Value* value)
{
+ if (value->isBool()) {
+ out = CacheVariable{
+ /*Type=*/"BOOL",
+ /*Value=*/value->asBool() ? "TRUE" : "FALSE",
+ };
+ return ReadFileResult::READ_OK;
+ }
if (value->isString()) {
out = CacheVariable{
/*Type=*/"",