Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Jamie Fox | b93da8b | 2018-12-13 18:27:30 +0000 | [diff] [blame] | 2 | # Copyright (c) 2017-2019, Arm Limited. All rights reserved. |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | cmake_minimum_required(VERSION 3.7) |
| 9 | |
| 10 | #Tell cmake where our modules can be found |
| 11 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake) |
| 12 | |
| 13 | #Include common stuff to control cmake. |
| 14 | include("Common/BuildSys") |
| 15 | |
Gyorgy Szing | 5b15f85 | 2018-09-24 17:07:36 +0200 | [diff] [blame] | 16 | #Include functionality to enable building the documentation. |
| 17 | include("Common/BuildDoxygenDoc") |
Gyorgy Szing | 74dae3c | 2018-09-27 17:00:46 +0200 | [diff] [blame] | 18 | include("Common/BuildSphinxDoc") |
Gyorgy Szing | 5b15f85 | 2018-09-24 17:07:36 +0200 | [diff] [blame] | 19 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 20 | #Start an embedded project. |
| 21 | embedded_project_start(CONFIG "${CMAKE_CURRENT_LIST_DIR}/../ConfigDefault.cmake") |
| 22 | project(tfm_s LANGUAGES ASM C) |
| 23 | embedded_project_fixup() |
| 24 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 25 | set(SECURE_FW_DIR "${CMAKE_CURRENT_LIST_DIR}") |
| 26 | set(TFM_ROOT_DIR "${SECURE_FW_DIR}/..") |
| 27 | set(TEST_DIR "${TFM_ROOT_DIR}/test") |
| 28 | set(INTERFACE_DIR "${TFM_ROOT_DIR}/interface") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 29 | |
Tamas Ban | 3109b30 | 2018-08-15 14:51:58 +0100 | [diff] [blame] | 30 | if (NOT DEFINED TFM_LVL) |
| 31 | message(FATAL_ERROR "Incomplete build configuration: TFM_LVL is undefined. ") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 32 | endif() |
| 33 | |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 34 | if (NOT DEFINED TFM_PARTITION_AUDIT_LOG) |
| 35 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_AUDIT_LOG is undefined.") |
| 36 | endif() |
| 37 | |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 38 | if (NOT DEFINED TFM_PARTITION_PLATFORM) |
| 39 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_PLATFORM is undefined.") |
| 40 | endif() |
| 41 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 42 | include(${SECURE_FW_DIR}/spm/CMakeLists.inc) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 43 | include(${SECURE_FW_DIR}/ns_callable/CMakeLists.inc) |
Edison Ai | f09acd4 | 2018-09-20 14:00:07 +0800 | [diff] [blame] | 44 | #Involve all IPC related sources in ipc's CMakeLists.inc, and switch core between IPC and Library. |
Ken Liu | b79a6f5 | 2018-07-18 16:36:02 +0800 | [diff] [blame] | 45 | if(TFM_PSA_API) |
| 46 | include(${SECURE_FW_DIR}/core/ipc/CMakeLists.inc) |
Edison Ai | f09acd4 | 2018-09-20 14:00:07 +0800 | [diff] [blame] | 47 | else() |
| 48 | include(${SECURE_FW_DIR}/core/CMakeLists.inc) |
Ken Liu | b79a6f5 | 2018-07-18 16:36:02 +0800 | [diff] [blame] | 49 | endif() |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 50 | |
Marc Moreno Berengue | a1f296f | 2018-01-25 15:21:22 +0000 | [diff] [blame] | 51 | set(BUILD_CMSIS_CORE On) |
| 52 | set(BUILD_RETARGET On) |
| 53 | set(BUILD_NATIVE_DRIVERS On) |
| 54 | set(BUILD_STARTUP On) |
| 55 | set(BUILD_TARGET_CFG On) |
Marc Moreno Berengue | 4cc81fc | 2018-08-10 14:32:01 +0100 | [diff] [blame] | 56 | # FIXME: The following TARGET flags are platform dependent. |
| 57 | # It is required to add a mechanism to expose the |
| 58 | # target capabilities and, based on them, set the |
| 59 | # flags properly. |
Marc Moreno Berengue | a1f296f | 2018-01-25 15:21:22 +0000 | [diff] [blame] | 60 | set(BUILD_TARGET_HARDWARE_KEYS On) |
Marc Moreno Berengue | 4cc81fc | 2018-08-10 14:32:01 +0100 | [diff] [blame] | 61 | set(BUILD_TARGET_NV_COUNTERS On) |
Marc Moreno Berengue | a1f296f | 2018-01-25 15:21:22 +0000 | [diff] [blame] | 62 | set(BUILD_CMSIS_DRIVERS On) |
| 63 | set(BUILD_TIME Off) |
| 64 | set(BUILD_UART_STDOUT On) |
Marc Moreno Berengue | 792fc68 | 2018-02-20 11:53:30 +0000 | [diff] [blame] | 65 | set(BUILD_FLASH On) |
Tamas Ban | 3681ce0 | 2018-11-22 15:19:24 +0000 | [diff] [blame] | 66 | set(BUILD_BOOT_SEED On) |
Tamas Ban | 38e1731 | 2018-11-22 15:26:35 +0000 | [diff] [blame] | 67 | set(BUILD_DEVICE_ID On) |
Marc Moreno Berengue | a1f296f | 2018-01-25 15:21:22 +0000 | [diff] [blame] | 68 | if(NOT DEFINED PLATFORM_CMAKE_FILE) |
| 69 | message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.") |
| 70 | elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE}) |
| 71 | message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.") |
| 72 | else() |
| 73 | include(${PLATFORM_CMAKE_FILE}) |
| 74 | endif() |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 75 | |
Mate Toth-Pal | 48fc6a0 | 2018-01-24 09:50:14 +0100 | [diff] [blame] | 76 | if(NOT DEFINED S_SCATTER_FILE_NAME) |
| 77 | message(FATAL_ERROR "ERROR: Incomplete Configuration: S_SCATTER_FILE_NAME not defined, Include this file from a Config*.cmake") |
| 78 | endif() |
Gabor Kertesz | d7d7d74 | 2018-07-04 11:50:05 +0200 | [diff] [blame] | 79 | embedded_set_target_linker_file(TARGET ${PROJECT_NAME} PATH "${S_SCATTER_FILE_NAME}") |
| 80 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 81 | embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${TFM_ROOT_DIR} ABSOLUTE APPEND) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 82 | #Create an object library to avoid compiling all source files twice, when two executables |
| 83 | #with different memory map need to be linked(BL2 non-swapping) |
| 84 | set(PROJECT_OBJ_LIB ${PROJECT_NAME}_obj_lib) |
| 85 | add_library(${PROJECT_OBJ_LIB} OBJECT ${ALL_SRC_C} ${ALL_SRC_C_S} ${ALL_SRC_ASM_S}) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 86 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 87 | #Set common compiler flags |
| 88 | config_setting_shared_compiler_flags(${PROJECT_OBJ_LIB}) |
| 89 | |
Marc Moreno Berengue | 4cc81fc | 2018-08-10 14:32:01 +0100 | [diff] [blame] | 90 | if(NOT DEFINED TARGET_NV_COUNTERS_ENABLE) |
| 91 | set(TARGET_NV_COUNTERS_ENABLE OFF) |
| 92 | endif() |
| 93 | |
| 94 | if(TARGET_NV_COUNTERS_ENABLE) |
| 95 | embedded_set_target_compile_defines(TARGET ${PROJECT_OBJ_LIB} LANGUAGE C DEFINES TFM_NVCOUNTERS_ENABLE APPEND) |
| 96 | endif() |
| 97 | |
Miklos Balint | 16a9ffb | 2018-11-19 11:35:49 +0100 | [diff] [blame] | 98 | if (NOT DEFINED CORE_TEST) |
| 99 | message(FATAL_ERROR "Incomplete build configuration: CORE_TEST is undefined.") |
| 100 | elseif(CORE_TEST) |
Jamie Fox | adf0255 | 2019-05-16 17:44:52 +0100 | [diff] [blame] | 101 | embedded_set_target_compile_defines(TARGET ${PROJECT_OBJ_LIB} LANGUAGE C DEFINES TFM_CORE_DEBUG APPEND) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 102 | endif() |
| 103 | |
Miklos Balint | 16a9ffb | 2018-11-19 11:35:49 +0100 | [diff] [blame] | 104 | if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION) |
| 105 | message(FATAL_ERROR "Incomplete build configuration: TFM_NS_CLIENT_IDENTIFICATION is undefined.") |
| 106 | elseif (TFM_NS_CLIENT_IDENTIFICATION) |
| 107 | target_compile_definitions(${PROJECT_OBJ_LIB} PRIVATE TFM_NS_CLIENT_IDENTIFICATION) |
| 108 | endif() |
| 109 | |
Mate Toth-Pal | cf32b90 | 2019-04-08 18:22:51 +0200 | [diff] [blame] | 110 | if (NOT DEFINED DEBUG_AUTHENTICATION) |
| 111 | set(DEBUG_AUTHENTICATION "DAUTH_CHIP_DEFAULT") |
| 112 | endif() |
| 113 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 114 | #Set include directories |
| 115 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TFM_ROOT_DIR} ABSOLUTE APPEND) |
| 116 | |
| 117 | # For the non-swapping BL2 configuration two executables need to be built. |
| 118 | # One can be executed from flash partition slot_0 and other from slot_1. |
| 119 | # Only the linking phase is different. This function captures common settings |
| 120 | # and eliminates copy-paste. |
| 121 | function(set_up_secure_fw_build) |
| 122 | set( _OPTIONS_ARGS) #Option (on/off) arguments (e.g. IGNORE_CASE) |
| 123 | set( _ONE_VALUE_ARGS S_TARGET VENEER_NAME POSTFIX) #Single option arguments (e.g. PATH "./foo/bar") |
| 124 | set( _MULTI_VALUE_ARGS LINK_DEFINES) #List arguments (e.g. LANGUAGES C ASM CXX) |
| 125 | cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN}) |
| 126 | |
| 127 | if (NOT DEFINED _MY_PARAMS_S_TARGET) |
| 128 | message(FATAL_ERROR "set_up_secure_fw_build(): mandatory parameter 'S_TARGET' missing.") |
| 129 | endif() |
| 130 | |
| 131 | if (NOT DEFINED _MY_PARAMS_VENEER_NAME) |
| 132 | message(FATAL_ERROR "set_up_secure_fw_build(): mandatory parameter 'VENEER_NAME' missing.") |
| 133 | endif() |
| 134 | |
| 135 | set(EXE_NAME ${_MY_PARAMS_S_TARGET}${_MY_PARAMS_POSTFIX}) |
| 136 | set(VENEER_NAME ${_MY_PARAMS_VENEER_NAME}${_MY_PARAMS_POSTFIX}.o) |
| 137 | |
| 138 | #Create linker target: add object library to executable |
| 139 | add_executable(${EXE_NAME} $<TARGET_OBJECTS:${PROJECT_OBJ_LIB}>) |
| 140 | |
| 141 | #Set common linker flags |
| 142 | config_setting_shared_linker_flags(${EXE_NAME}) |
| 143 | |
| 144 | #Indicates to secure target(s) already created |
| 145 | set(TARGET_TFM_S_EXISTED True PARENT_SCOPE) |
| 146 | |
| 147 | #Set individual linker flags per linker target/executable |
| 148 | foreach(flag ${_MY_PARAMS_LINK_DEFINES}) |
| 149 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "${flag}") |
| 150 | endforeach(flag) |
| 151 | |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 152 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 153 | embedded_set_target_linker_file(TARGET ${EXE_NAME} PATH "${S_SCATTER_FILE_NAME}") |
| 154 | |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 155 | add_dependencies(${EXE_NAME} tfm_crypto) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 156 | add_dependencies(${EXE_NAME} tfm_storage) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 157 | add_dependencies(${EXE_NAME} tfm_secure_tests) |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 158 | add_dependencies(${EXE_NAME} tfm_attest) |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 159 | if (TFM_PARTITION_AUDIT_LOG) |
| 160 | add_dependencies(${EXE_NAME} tfm_audit) |
| 161 | endif() |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 162 | if (TFM_PARTITION_PLATFORM) |
| 163 | add_dependencies(${EXE_NAME} tfm_platform) |
| 164 | endif() |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 165 | |
| 166 | #Set macro definitions for the project. |
Mate Toth-Pal | cf32b90 | 2019-04-08 18:22:51 +0200 | [diff] [blame] | 167 | embedded_set_target_compile_defines(TARGET ${PROJECT_OBJ_LIB} LANGUAGE C DEFINES __thumb2__ __ARM_FEATURE_CMSE=3 TFM_LVL=${TFM_LVL} ${DEBUG_AUTHENTICATION} APPEND) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 168 | |
Jamie Fox | adf0255 | 2019-05-16 17:44:52 +0100 | [diff] [blame] | 169 | if (REGRESSION OR CORE_TEST) |
Jamie Fox | b93da8b | 2018-12-13 18:27:30 +0000 | [diff] [blame] | 170 | if (DEFINED TFM_PARTITION_TEST_SECURE_SERVICES AND TFM_PARTITION_TEST_SECURE_SERVICES) |
Mate Toth-Pal | 8d7f12b | 2018-06-18 17:40:09 +0200 | [diff] [blame] | 171 | #The test service veneers in the tfm_secure_tests library may not be |
| 172 | #referenced in the secure binary so the veneer objects are explicitly loaded |
| 173 | #from the secure tests library. However by generating the veneer files from |
| 174 | #the manifests, all the iovec interfaced veneers are in a single file in the |
| 175 | #secure_fw directory. The core test partitions use the veneers with the |
Jamie Fox | b93da8b | 2018-12-13 18:27:30 +0000 | [diff] [blame] | 176 | #iovec API, so we only need the explicit load in case the secure client test |
| 177 | #partition is present. |
| 178 | #FIXME Remove the explicit load and the above comment once the secure client |
| 179 | #test partition uses the generated veneers. |
Miklos Balint | dd02bb3 | 2019-05-26 21:13:12 +0200 | [diff] [blame] | 180 | if((${COMPILER} STREQUAL "ARMCLANG") AND (NOT TFM_PSA_API)) |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 181 | target_link_libraries(${EXE_NAME} tfm_attest tfm_secure_tests tfm_attest tfm_crypto tfm_storage $<TARGET_LINKER_FILE:tfm_secure_tests>\(*veneers.o\) tfm_attest) |
Mate Toth-Pal | 8d7f12b | 2018-06-18 17:40:09 +0200 | [diff] [blame] | 182 | else() |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 183 | target_link_libraries(${EXE_NAME} tfm_attest tfm_secure_tests tfm_attest tfm_crypto tfm_storage tfm_attest) |
Mate Toth-Pal | 8d7f12b | 2018-06-18 17:40:09 +0200 | [diff] [blame] | 184 | endif() |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 185 | else() |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 186 | target_link_libraries(${EXE_NAME} tfm_attest tfm_crypto tfm_storage tfm_secure_tests tfm_attest) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 187 | endif() |
| 188 | else() |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 189 | target_link_libraries(${EXE_NAME} tfm_attest tfm_crypto tfm_storage tfm_attest) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 190 | endif() |
| 191 | |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 192 | if (TFM_PARTITION_AUDIT_LOG) |
| 193 | target_link_libraries(${EXE_NAME} tfm_audit) |
| 194 | endif() |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 195 | |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 196 | if (TFM_PARTITION_PLATFORM) |
| 197 | target_link_libraries(${EXE_NAME} tfm_platform) |
| 198 | endif() |
| 199 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 200 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_LVL=${TFM_LVL}") |
| 201 | |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 202 | if (TFM_PARTITION_AUDIT_LOG) |
| 203 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_AUDIT_LOG") |
| 204 | endif() |
| 205 | |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 206 | if (TFM_PARTITION_PLATFORM) |
| 207 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_PLATFORM") |
| 208 | endif() |
| 209 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 210 | if (NOT DEFINED TFM_PARTITION_TEST_CORE) |
| 211 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_CORE is undefined. ") |
| 212 | elseif (TFM_PARTITION_TEST_CORE) |
| 213 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_CORE") |
| 214 | endif() |
| 215 | |
Jamie Fox | adf0255 | 2019-05-16 17:44:52 +0100 | [diff] [blame] | 216 | if (NOT DEFINED TFM_PARTITION_TEST_CORE_IPC) |
| 217 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_CORE_IPC is undefined.") |
| 218 | elseif (TFM_PARTITION_TEST_CORE_IPC) |
| 219 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_CORE_IPC") |
| 220 | endif() |
| 221 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 222 | if (NOT DEFINED TFM_PARTITION_TEST_SECURE_SERVICES) |
| 223 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_SECURE_SERVICES is undefined. ") |
| 224 | elseif (TFM_PARTITION_TEST_SECURE_SERVICES) |
| 225 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_SECURE_SERVICES") |
| 226 | endif() |
| 227 | |
Marc Moreno Berengue | cae2c53 | 2018-10-09 12:58:46 +0100 | [diff] [blame] | 228 | if (NOT DEFINED TEST_FRAMEWORK_S) |
| 229 | message(FATAL_ERROR "Incomplete build configuration: TEST_FRAMEWORK_S is undefined.") |
| 230 | elseif (TEST_FRAMEWORK_S) |
| 231 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TEST_FRAMEWORK_S") |
| 232 | endif() |
| 233 | |
| 234 | if (NOT DEFINED TEST_FRAMEWORK_NS) |
| 235 | message(FATAL_ERROR "Incomplete build configuration: TEST_FRAMEWORK_NS is undefined.") |
| 236 | elseif (TEST_FRAMEWORK_NS) |
| 237 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TEST_FRAMEWORK_NS") |
| 238 | endif() |
| 239 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 240 | if (NOT DEFINED BL2) |
| 241 | message(FATAL_ERROR "Incomplete build configuration: BL2 is undefined. ") |
| 242 | elseif (BL2) |
| 243 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "BL2") |
| 244 | endif() |
| 245 | |
Summer Qin | 1188301 | 2018-07-04 16:36:21 +0800 | [diff] [blame] | 246 | if (NOT DEFINED TFM_PSA_API) |
| 247 | message(FATAL_ERROR "Incomplete build configuration: TFM_PSA_API is undefined. ") |
| 248 | elseif (TFM_PSA_API) |
Tamas Ban | e2dcd7e | 2019-05-27 08:36:32 +0100 | [diff] [blame] | 249 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PSA_API") |
Summer Qin | 1188301 | 2018-07-04 16:36:21 +0800 | [diff] [blame] | 250 | endif() |
| 251 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 252 | if(CORE_TEST) |
| 253 | set(SECURE_AXF_DIR_PREFIX "${CMAKE_BINARY_DIR}/unit_test/") |
| 254 | set_target_properties(${EXE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${SECURE_AXF_DIR_PREFIX}) |
| 255 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_CORE") |
| 256 | endif() |
| 257 | |
| 258 | if(NOT DEFINED PLATFORM_LINK_INCLUDES) |
| 259 | message(FATAL_ERROR "ERROR: Incomplete Configuration: PLATFORM_LINK_INCLUDES is not defined.") |
| 260 | endif() |
| 261 | embedded_set_target_link_includes(TARGET ${EXE_NAME} INCLUDES "${PLATFORM_LINK_INCLUDES}") |
| 262 | |
| 263 | #Generate binary file from executable |
| 264 | compiler_generate_binary_output(${EXE_NAME}) |
| 265 | |
| 266 | #Configure where we put the CMSE veneers generated by the compiler. |
| 267 | if (DEFINED S_VENEER_FILE_LOCATION) |
| 268 | set(S_VENEER_FILE "${S_VENEER_FILE_LOCATION}/${VENEER_NAME}") |
| 269 | else() |
| 270 | set(S_VENEER_FILE "${CMAKE_CURRENT_BINARY_DIR}/${VENEER_NAME}") |
| 271 | endif() |
| 272 | compiler_set_cmse_output(${EXE_NAME} "${S_VENEER_FILE}") |
| 273 | |
| 274 | #Configure what file shall be installed. |
| 275 | #Set install location. Keep original value to avoid overriding command line settings. |
| 276 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 277 | set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Default install location for secure_fw." FORCE) |
| 278 | endif() |
| 279 | |
Mate Toth-Pal | 8d7f12b | 2018-06-18 17:40:09 +0200 | [diff] [blame] | 280 | #Export files needed to interface external applications at: <build_dir>/install/export/tfm/ |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 281 | install(DIRECTORY ${TFM_ROOT_DIR}/interface/include/ |
Tamas Ban | 57bfa43 | 2018-04-13 16:05:49 +0100 | [diff] [blame] | 282 | DESTINATION export/tfm/inc) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 283 | |
| 284 | install(DIRECTORY ${TFM_ROOT_DIR}/interface/src/ |
Tamas Ban | 57bfa43 | 2018-04-13 16:05:49 +0100 | [diff] [blame] | 285 | DESTINATION export/tfm/src) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 286 | |
Tamas Ban | 57bfa43 | 2018-04-13 16:05:49 +0100 | [diff] [blame] | 287 | install(FILES ${S_VENEER_FILE} DESTINATION export/tfm/veneers) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 288 | |
Tamas Ban | 57bfa43 | 2018-04-13 16:05:49 +0100 | [diff] [blame] | 289 | #Collect executables to common location: <build_dir>/install/outputs/ |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 290 | if (DEFINED SECURE_AXF_DIR_PREFIX) |
| 291 | set(MY_BINARY_DIR ${SECURE_AXF_DIR_PREFIX}) |
| 292 | else() |
| 293 | set(MY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
| 294 | endif() |
| 295 | |
| 296 | install(FILES ${MY_BINARY_DIR}/${EXE_NAME}.axf |
| 297 | ${MY_BINARY_DIR}/${EXE_NAME}.bin |
| 298 | DESTINATION outputs/${TARGET_PLATFORM}/) |
| 299 | |
| 300 | install(FILES ${MY_BINARY_DIR}/${EXE_NAME}.axf |
| 301 | ${MY_BINARY_DIR}/${EXE_NAME}.bin |
| 302 | DESTINATION outputs/fvp/) |
| 303 | endfunction() |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 304 | |
| 305 | #Adds the test directory |
| 306 | add_subdirectory(${TFM_ROOT_DIR}/test ${CMAKE_BINARY_DIR}/test) |
| 307 | |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 308 | #Add the crypto library target |
| 309 | add_subdirectory(${SECURE_FW_DIR}/services/crypto) |
| 310 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 311 | #Add the secure storage library target |
| 312 | add_subdirectory(${SECURE_FW_DIR}/services/secure_storage) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 313 | |
Marc Moreno Berengue | 8e0fa7a | 2018-10-04 18:25:13 +0100 | [diff] [blame] | 314 | #Add the platform service library target |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 315 | if (TFM_PARTITION_PLATFORM) |
| 316 | add_subdirectory(${SECURE_FW_DIR}/services/platform) |
| 317 | endif() |
Marc Moreno Berengue | 8e0fa7a | 2018-10-04 18:25:13 +0100 | [diff] [blame] | 318 | |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 319 | #Add the initial attestation service library target |
| 320 | add_subdirectory(${SECURE_FW_DIR}/services/initial_attestation) |
| 321 | |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 322 | #Add the audit logging library target |
| 323 | if (TFM_PARTITION_AUDIT_LOG) |
| 324 | add_subdirectory(${SECURE_FW_DIR}/services/audit_logging) |
| 325 | endif() |
| 326 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 327 | if (LINK_TO_BOTH_MEMORY_REGION) |
| 328 | #Link to primary memory region |
| 329 | set_up_secure_fw_build(S_TARGET ${PROJECT_NAME} |
Tamas Ban | bba8564 | 2019-06-06 09:31:59 +0100 | [diff] [blame^] | 330 | VENEER_NAME s_veneers) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 331 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 332 | #Link to secondary memory region(add extra linker flag) |
| 333 | set_up_secure_fw_build(S_TARGET ${PROJECT_NAME} |
| 334 | LINK_DEFINES "LINK_TO_SECONDARY_PARTITION" |
| 335 | VENEER_NAME s_veneers |
| 336 | POSTFIX "_1") |
Jamie Fox | 5592db0 | 2017-12-18 16:48:29 +0000 | [diff] [blame] | 337 | else() |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 338 | #Link to primary memory region only |
| 339 | set_up_secure_fw_build(S_TARGET ${PROJECT_NAME} |
| 340 | VENEER_NAME s_veneers) |
Jamie Fox | 5592db0 | 2017-12-18 16:48:29 +0000 | [diff] [blame] | 341 | endif() |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 342 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 343 | #Finally let CMake system apply changes after the whole project is defined. |
| 344 | if (TARGET ${PROJECT_NAME}) |
| 345 | embedded_project_end(${PROJECT_NAME}) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 346 | endif() |
| 347 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 348 | if (TARGET ${PROJECT_NAME}_1) |
| 349 | embedded_project_end(${PROJECT_NAME}_1) |
Ben Davis | 6d7256b | 2018-04-18 14:16:53 +0100 | [diff] [blame] | 350 | endif() |
| 351 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 352 | embedded_project_end(${PROJECT_OBJ_LIB}) |