Add platform support
TS project structure and build system extended to accommodate
hardware specific drivers. The concept of a platform is introduced
to allow hardware specific drivers from external providers to be
used. This change implements the Portability Model described in
the project documentation.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I61e678ae103e0bf139f2c440ba6cd010620af37e
diff --git a/tools/cmake/common/AddPlatform.cmake b/tools/cmake/common/AddPlatform.cmake
new file mode 100644
index 0000000..ae34c6e
--- /dev/null
+++ b/tools/cmake/common/AddPlatform.cmake
@@ -0,0 +1,45 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#[===[.rst:
+Add platform provided components to a build
+-------------------------------------------
+
+#]===]
+
+
+#[===[.rst:
+.. cmake:command:: add_platform
+
+ .. code:: cmake
+
+ add_platform(TARGET <target name>)
+
+ INPUTS:
+
+ ``TARGET``
+ The name of an already defined target to add platform components to.
+
+#]===]
+function(add_platform)
+ set(options )
+ set(oneValueArgs TARGET)
+ cmake_parse_arguments(MY_PARAMS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
+
+ if(NOT DEFINED MY_PARAMS_TARGET)
+ message(FATAL_ERROR "add_platform: mandatory parameter TARGET not defined!")
+ endif()
+
+ set(TGT ${MY_PARAMS_TARGET} CACHE STRING "")
+
+ # Ensure file path conforms to lowercase project convention
+ string(TOLOWER "${TS_PLATFORM_ROOT}/${TS_PLATFORM}/platform.cmake" _platdef)
+ include(${_platdef})
+ set(CMAKE_CONFIGURE_DEPENDS ${_platdef})
+
+ unset(TGT CACHE)
+endfunction()