1#-------------------------------------------------------------------------------
2# Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8#[===[.rst:
9Add platform provided components to a build
10-------------------------------------------
11
12#]===]
13
14
15#[===[.rst:
16.. cmake:command:: add_platform
17
18	.. code:: cmake
19
20		add_platform(TARGET <target name>)
21
22	INPUTS:
23
24	``TARGET``
25	The name of an already defined target to add platform components to.
26
27	``TS_PLATFORM``
28	This global variable is used to construct a path to the platform specific cmake file.
29	:variable:TS_PLATFORM can be set from the command line and the value must be lower case.
30
31#]===]
32function(add_platform)
33	set(options  )
34	set(oneValueArgs TARGET)
35	cmake_parse_arguments(MY_PARAMS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
36
37	if(NOT DEFINED MY_PARAMS_TARGET)
38		message(FATAL_ERROR "add_platform: mandatory parameter TARGET not defined!")
39	endif()
40
41	# Ensure file path conforms to lowercase project convention
42	string(TOLOWER "${TS_PLATFORM}" _tmp)
43	if (NOT "${TS_PLATFORM}" STREQUAL "${_tmp}")
44			message(FATAL_ERROR "Value of TS_PLATFORM may only use lowercase letters. The current value"
45								" \"${TS_PLATFORM}\" violates this.")
46	endif()
47	set(TGT ${MY_PARAMS_TARGET})
48	include(${TS_PLATFORM_ROOT}/${TS_PLATFORM}/platform.cmake)
49endfunction()
50