build(cmake): add metadata management utilities

This change introduces what we will refer to as the "global metadata
file": `metadata.json`. We will use this file going forward to declare
static, project-wide configuration data. This allows us to reduce the
amount of churn going on in the CMake script list files - which are
going to be much less familiar to newcomers - to support new platforms,
cores and features.

To facilitate rapid retrieval of structured (JSON-based) project data,
an additional set of CMake utilities are introduced here to simplify
retrieval and manipulation of the project metadata from the scripts.

Change-Id: Idd8518fb17e7a309f82344e228ddecc6e329792b
Signed-off-by: Chris Kay <chris.kay@arm.com>
diff --git a/cmake/Modules/TFAMetadata.cmake b/cmake/Modules/TFAMetadata.cmake
new file mode 100644
index 0000000..56243cc
--- /dev/null
+++ b/cmake/Modules/TFAMetadata.cmake
@@ -0,0 +1,41 @@
+#[=======================================================================[.rst:
+TFAMetadata
+-----------
+
+.. default-domain:: cmake
+
+Metadata management utilities for TF-A.
+
+TF-A uses a set of JSON-formatted metadata files to manage some of its
+configuration data. This module provides a stable CMake interface for retrieving
+values from these metadata files.
+#]=======================================================================]
+
+include_guard()
+
+include(ArmAssert)
+include(ArmExpand)
+
+include(TFAJsonUtilities)
+
+#
+# Read the global metadata file. This is a JSON-formatted file that contains
+# information about the contents of the repository that are relevant to the
+# build system.
+#
+
+arm_assert(CONDITION EXISTS "${CMAKE_SOURCE_DIR}/metadata.json")
+
+file(READ "${CMAKE_SOURCE_DIR}/metadata.json" global-metadata)
+arm_expand(OUTPUT global-metadata STRING "${global-metadata}")
+
+#
+# Internal global metadata API.
+#
+
+tfa_json_getter(tfa_metadata
+    JSON "${global-metadata}")
+
+#
+# External global metadata API.
+#