julhal01 | ffa98d8 | 2021-01-20 13:51:58 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Vishnu Banavath | 79d9f5d | 2022-08-03 11:07:05 +0100 | [diff] [blame] | 2 | # Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved. |
julhal01 | ffa98d8 | 2021-01-20 13:51:58 +0000 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | #[===[.rst: |
| 9 | Add 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 Banavath | 79d9f5d | 2022-08-03 11:07:05 +0100 | [diff] [blame] | 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 | |
julhal01 | ffa98d8 | 2021-01-20 13:51:58 +0000 | [diff] [blame] | 31 | #]===] |
| 32 | function(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 | |
julhal01 | ffa98d8 | 2021-01-20 13:51:58 +0000 | [diff] [blame] | 41 | # Ensure file path conforms to lowercase project convention |
Vishnu Banavath | 79d9f5d | 2022-08-03 11:07:05 +0100 | [diff] [blame] | 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) |
julhal01 | ffa98d8 | 2021-01-20 13:51:58 +0000 | [diff] [blame] | 49 | endfunction() |