1# Copyright (c) 2022 Arm Limited (or its affiliates). All rights reserved.
2# SPDX-License-Identifier: Apache-2.0
3
4if (CONFIG_BUILD_WITH_TFA)
5  set(TFA_BINARY_DIR ${CMAKE_BINARY_DIR}/tfa)
6
7  file(MAKE_DIRECTORY ${TFA_BINARY_DIR})
8
9  include(ExternalProject)
10
11  ExternalProject_Add(
12    tfa
13    SOURCE_DIR ${ZEPHYR_TRUSTED_FIRMWARE_A_MODULE_DIR}
14    BINARY_DIR ${TFA_BINARY_DIR}
15    CONFIGURE_COMMAND ""
16    BUILD_COMMAND ""
17    INSTALL_COMMAND ""
18    BUILD_ALWAYS True
19    USES_TERMINAL_BUILD True
20  )
21
22  if (CONFIG_TFA_MAKE_BUILD_TYPE_DEBUG)
23    set(TFA_BUILD_DEBUG "1")
24  else()
25    set(TFA_BUILD_DEBUG "0")
26  endif()
27
28  set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
29      COMMAND make -C ${ZEPHYR_TRUSTED_FIRMWARE_A_MODULE_DIR}
30            DEBUG=${TFA_BUILD_DEBUG}
31            CROSS_COMPILE=${CROSS_COMPILE}
32            BUILD_BASE=${TFA_BINARY_DIR} PLAT=${TFA_PLAT}
33            BL33=${CMAKE_BINARY_DIR}/zephyr/${KERNEL_BIN_NAME}
34            all fip
35  )
36endif()
37