summaryrefslogtreecommitdiffstats
path: root/Source/cmPlistParser.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2023-05-17 17:50:32 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2023-07-26 21:00:01 (GMT)
commit7050ac56a11768c90f55654aa3f63d02bb549243 (patch)
treea436ee5be767bfd776dc93d747abd122a94f3a34 /Source/cmPlistParser.cxx
parent93ed53790cb1e2d5f25f26156ee5c6590b0d3150 (diff)
downloadCMake-7050ac56a11768c90f55654aa3f63d02bb549243.zip
CMake-7050ac56a11768c90f55654aa3f63d02bb549243.tar.gz
CMake-7050ac56a11768c90f55654aa3f63d02bb549243.tar.bz2
macOS: Add support for linking against .xcframework folders
Issue: #21752
Diffstat (limited to 'Source/cmPlistParser.cxx')
-rw-r--r--Source/cmPlistParser.cxx33
1 files changed, 33 insertions, 0 deletions
diff --git a/Source/cmPlistParser.cxx b/Source/cmPlistParser.cxx
new file mode 100644
index 0000000..ce3c171
--- /dev/null
+++ b/Source/cmPlistParser.cxx
@@ -0,0 +1,33 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmPlistParser.h"
+
+#include <cm3p/json/reader.h>
+#include <cm3p/json/value.h>
+
+#include "cmUVProcessChain.h"
+#include "cmUVStream.h"
+
+cm::optional<Json::Value> cmParsePlist(const std::string& filename)
+{
+ cmUVProcessChainBuilder builder;
+ builder.AddCommand(
+ { "/usr/bin/plutil", "-convert", "json", "-o", "-", filename });
+ builder.SetBuiltinStream(cmUVProcessChainBuilder::Stream_OUTPUT);
+
+ auto chain = builder.Start();
+ chain.Wait();
+
+ auto const& status = chain.GetStatus(0);
+ if (status.ExitStatus != 0) {
+ return cm::nullopt;
+ }
+
+ Json::Reader reader;
+ Json::Value value;
+ cmUVPipeIStream outputStream(chain.GetLoop(), chain.OutputStream());
+ if (!reader.parse(outputStream, value)) {
+ return cm::nullopt;
+ }
+ return cm::optional<Json::Value>(value);
+}