blob: 37efdf2fa8cf50e77460ed1e1d24a99134525e30 [file] [log] [blame]
julhal01ffa98d82021-01-20 13:51:58 +00001#-------------------------------------------------------------------------------
Vishnu Banavath79d9f5d2022-08-03 11:07:05 +01002# Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
julhal01ffa98d82021-01-20 13:51:58 +00003#
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
Vishnu Banavath79d9f5d2022-08-03 11:07:05 +010027 ``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
julhal01ffa98d82021-01-20 13:51:58 +000031#]===]
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
julhal01ffa98d82021-01-20 13:51:58 +000041 # Ensure file path conforms to lowercase project convention
Vishnu Banavath79d9f5d2022-08-03 11:07:05 +010042 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)
julhal01ffa98d82021-01-20 13:51:58 +000049endfunction()