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