Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame^] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2017-2020, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | cmake_minimum_required(VERSION 3.7) |
| 9 | |
| 10 | set(TFM_BUILD_IN_SPE OFF) |
| 11 | |
| 12 | #Tell cmake where our modules can be found |
| 13 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake) |
| 14 | |
| 15 | set(APP_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 16 | get_filename_component(TFM_ROOT_DIR ${APP_DIR}/.. ABSOLUTE) |
| 17 | set(INTERFACE_DIR ${TFM_ROOT_DIR}/interface) |
| 18 | |
| 19 | #Include common stuff to control cmake. |
| 20 | include("Common/BuildSys") |
| 21 | |
| 22 | #Start an embedded project. |
| 23 | embedded_project_start(CONFIG "${TFM_ROOT_DIR}/configs/ConfigDefault.cmake") |
| 24 | project(tfm_ns LANGUAGES ASM C) |
| 25 | embedded_project_fixup() |
| 26 | |
| 27 | #Include BL2 bootloader related functions |
| 28 | set(MCUBOOT_DIR "${TFM_ROOT_DIR}/bl2/ext/mcuboot") |
| 29 | include("${MCUBOOT_DIR}/MCUBoot.cmake") |
| 30 | |
| 31 | #CMSIS |
| 32 | get_filename_component(CMSIS_DIR ${TFM_ROOT_DIR}/../tf-m-tests/CMSIS ABSOLUTE) |
| 33 | |
| 34 | if(NOT EXISTS ${CMSIS_DIR}) |
| 35 | message(FATAL_ERROR "Missing CMSIS. Please clone the tf-m-tests repo.") |
| 36 | endif() |
| 37 | |
| 38 | if (NOT DEFINED BL2) |
| 39 | message(FATAL_ERROR "Incomplete build configuration: BL2 is undefined. ") |
| 40 | endif () |
| 41 | |
| 42 | if (NOT DEFINED TFM_PARTITION_AUDIT_LOG) |
| 43 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_AUDIT_LOG is undefined.") |
| 44 | endif() |
| 45 | |
| 46 | if (NOT DEFINED TFM_PARTITION_PLATFORM) |
| 47 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_PLATFORM is undefined.") |
| 48 | endif() |
| 49 | |
| 50 | if (NOT DEFINED TFM_PARTITION_PROTECTED_STORAGE) |
| 51 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_PROTECTED_STORAGE is undefined.") |
| 52 | endif() |
| 53 | |
| 54 | if (NOT DEFINED TFM_PARTITION_INTERNAL_TRUSTED_STORAGE) |
| 55 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_INTERNAL_TRUSTED_STORAGE is undefined.") |
| 56 | endif() |
| 57 | |
| 58 | if (NOT DEFINED TFM_PARTITION_CRYPTO) |
| 59 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_CRYPTO is undefined.") |
| 60 | endif() |
| 61 | |
| 62 | if (NOT DEFINED TFM_PARTITION_INITIAL_ATTESTATION) |
| 63 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_INITIAL_ATTESTATION is undefined.") |
| 64 | endif() |
| 65 | |
| 66 | if (NOT DEFINED TFM_PSA_API) |
| 67 | message(FATAL_ERROR "Incomplete build configuration: TFM_PSA_API is undefined.") |
| 68 | endif() |
| 69 | |
| 70 | embedded_include_directories(PATH ${TFM_ROOT_DIR}/app ABSOLUTE) |
| 71 | |
| 72 | set(NS_APP_SRC "${CMSIS_DIR}/RTOS2/RTX/Config/RTX_Config.c" |
| 73 | "${CMSIS_DIR}/RTOS2/RTX/Source/rtx_lib.c" |
| 74 | "${APP_DIR}/main_ns.c" |
| 75 | "${APP_DIR}/tfm_integ_test.c" |
| 76 | "${APP_DIR}/os_wrapper_cmsis_rtos_v2.c" |
| 77 | "${TFM_ROOT_DIR}/interface/src/log/tfm_log_raw.c" |
| 78 | ) |
| 79 | |
| 80 | if (NOT DEFINED TFM_MULTI_CORE_TOPOLOGY OR NOT TFM_MULTI_CORE_TOPOLOGY) |
| 81 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_ns_interface.c") |
| 82 | endif() |
| 83 | |
| 84 | if (TFM_PARTITION_AUDIT_LOG) |
| 85 | if (TFM_PSA_API) |
| 86 | message(FATAL_ERROR "Audit log has not been supported in IPC model yet.") |
| 87 | else() |
| 88 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_audit_func_api.c") |
| 89 | endif() |
| 90 | endif() |
| 91 | |
| 92 | if (TFM_PARTITION_PLATFORM) |
| 93 | if (TFM_PSA_API) |
| 94 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_platform_ipc_api.c") |
| 95 | else() |
| 96 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_platform_func_api.c") |
| 97 | endif() |
| 98 | endif() |
| 99 | |
| 100 | if (TFM_PARTITION_PROTECTED_STORAGE) |
| 101 | if (TFM_PSA_API) |
| 102 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_ps_ipc_api.c") |
| 103 | else() |
| 104 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_ps_func_api.c") |
| 105 | endif() |
| 106 | endif() |
| 107 | |
| 108 | if (TFM_PARTITION_INTERNAL_TRUSTED_STORAGE) |
| 109 | if (TFM_PSA_API) |
| 110 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_its_ipc_api.c") |
| 111 | else() |
| 112 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_its_func_api.c") |
| 113 | endif() |
| 114 | endif() |
| 115 | |
| 116 | if (TFM_PARTITION_CRYPTO) |
| 117 | if (TFM_PSA_API) |
| 118 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_crypto_ipc_api.c") |
| 119 | else() |
| 120 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_crypto_func_api.c") |
| 121 | endif() |
| 122 | endif() |
| 123 | |
| 124 | if (TFM_PARTITION_INITIAL_ATTESTATION) |
| 125 | if (TFM_PSA_API) |
| 126 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_initial_attestation_ipc_api.c") |
| 127 | else() |
| 128 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_initial_attestation_func_api.c") |
| 129 | endif() |
| 130 | endif() |
| 131 | |
| 132 | if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION) |
| 133 | message(FATAL_ERROR "Incomplete build configuration: TFM_NS_CLIENT_IDENTIFICATION is undefined.") |
| 134 | elseif (TFM_NS_CLIENT_IDENTIFICATION) |
| 135 | list(APPEND NS_APP_SRC |
| 136 | "${INTERFACE_DIR}/src/tfm_nspm_svc_handler.c" |
| 137 | "${INTERFACE_DIR}/src/tfm_nspm_api.c" |
| 138 | ) |
| 139 | endif() |
| 140 | |
| 141 | if (PSA_API_TEST_NS) |
| 142 | list(APPEND NS_APP_SRC "${APP_DIR}/psa_api_test.c") |
| 143 | endif() |
| 144 | |
| 145 | if (TFM_PSA_API) |
| 146 | if (DEFINED TFM_MULTI_CORE_TOPOLOGY AND TFM_MULTI_CORE_TOPOLOGY) |
| 147 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_ns_mailbox.c" |
| 148 | "${INTERFACE_DIR}/src/tfm_multi_core_api.c" |
| 149 | "${INTERFACE_DIR}/src/tfm_multi_core_psa_ns_api.c" |
| 150 | ) |
| 151 | |
| 152 | if (TFM_MULTI_CORE_TEST) |
| 153 | add_definitions(-DTFM_MULTI_CORE_TEST) |
| 154 | endif() |
| 155 | else() |
| 156 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_psa_ns_api.c") |
| 157 | endif() |
| 158 | endif() |
| 159 | |
| 160 | set(BUILD_CMSIS_CORE On) |
| 161 | set(BUILD_RETARGET On) |
| 162 | set(BUILD_NATIVE_DRIVERS On) |
| 163 | set(BUILD_TIME On) |
| 164 | set(BUILD_STARTUP On) |
| 165 | set(BUILD_TARGET_CFG Off) |
| 166 | set(BUILD_TARGET_HARDWARE_KEYS Off) |
| 167 | set(BUILD_TARGET_NV_COUNTERS Off) |
| 168 | set(BUILD_CMSIS_DRIVERS On) |
| 169 | set(BUILD_UART_STDOUT On) |
| 170 | set(BUILD_FLASH Off) |
| 171 | if(CORE_TEST_POSITIVE) |
| 172 | set(BUILD_PLAT_TEST On) |
| 173 | set(BUILD_TIME On) |
| 174 | else() |
| 175 | set(BUILD_PLAT_TEST Off) |
| 176 | set(BUILD_TIME Off) |
| 177 | endif() |
| 178 | if(NOT DEFINED PLATFORM_CMAKE_FILE) |
| 179 | message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.") |
| 180 | elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE}) |
| 181 | message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.") |
| 182 | else() |
| 183 | include(${PLATFORM_CMAKE_FILE}) |
| 184 | endif() |
| 185 | |
| 186 | if(NOT DEFINED NS_SCATTER_FILE_NAME) |
| 187 | message(FATAL_ERROR "ERROR: Incomplete Configuration: NS_SCATTER_FILE_NAME not defined, Include this file from a Config*.cmake") |
| 188 | endif() |
| 189 | embedded_set_target_linker_file(TARGET ${PROJECT_NAME} PATH "${NS_SCATTER_FILE_NAME}") |
| 190 | |
| 191 | #Create an object library to avoid compiling all source files twice, when two executables |
| 192 | #with different memory map need to be linked(BL2 non-swapping) |
| 193 | set(PROJECT_OBJ_LIB ${PROJECT_NAME}_obj_lib) |
| 194 | add_library(${PROJECT_OBJ_LIB} OBJECT ${ALL_SRC_C} ${ALL_SRC_C_NS} ${ALL_SRC_ASM} ${ALL_SRC_ASM_NS} ${NS_APP_SRC}) |
| 195 | |
| 196 | #Set common compiler flags |
| 197 | config_setting_shared_compiler_flags(${PROJECT_OBJ_LIB}) |
| 198 | |
| 199 | #Set macro definitions |
| 200 | set(TARGET_COMPILE_DEFINITIONS __thumb2__ __DOMAIN_NS=1 DOMAIN_NS=__DOMAIN_NS) |
| 201 | target_compile_definitions(${PROJECT_OBJ_LIB} PRIVATE ${TARGET_COMPILE_DEFINITIONS}) |
| 202 | |
| 203 | #Set include directories. |
| 204 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TEST_INTERFACE_DIR}/include ABSOLUTE APPEND) |
| 205 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${INTERFACE_DIR}/include ABSOLUTE APPEND) |
| 206 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TFM_ROOT_DIR} ABSOLUTE APPEND) |
| 207 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TFM_ROOT_DIR}/secure_fw/spm ABSOLUTE APPEND) |
| 208 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${CMSIS_DIR}/RTOS2/RTX/Include ABSOLUTE APPEND) |
| 209 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${CMSIS_DIR}/RTOS2/Include ABSOLUTE APPEND) |
| 210 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${CMSIS_DIR}/RTOS2/RTX/Config ABSOLUTE APPEND) |
| 211 | |
| 212 | if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION) |
| 213 | message(FATAL_ERROR "Incomplete build configuration: TFM_NS_CLIENT_IDENTIFICATION is undefined.") |
| 214 | elseif (TFM_NS_CLIENT_IDENTIFICATION) |
| 215 | target_compile_definitions(${PROJECT_OBJ_LIB} PRIVATE TFM_NS_CLIENT_IDENTIFICATION) |
| 216 | endif() |
| 217 | |
| 218 | add_subdirectory(${TEST_DIR} ${CMAKE_BINARY_DIR}/test/non_secure_test) |
| 219 | |
| 220 | # For the non-swapping BL2 configuration two executables need to be built. |
| 221 | # One can be executed from the primary slot flash partition and other from the |
| 222 | # secondary slot. Only the linking phase is different. This function captures |
| 223 | # common settings and eliminates copy-paste. |
| 224 | function(set_up_app_build) |
| 225 | set( _OPTIONS_ARGS) #Option (on/off) arguments (e.g. IGNORE_CASE) |
| 226 | set( _ONE_VALUE_ARGS NS_TARGET S_TARGET FULL_BIN SIGN_BIN VENEER_NAME POSTFIX) #Single option arguments (e.g. PATH "./foo/bar") |
| 227 | set( _MULTI_VALUE_ARGS LINK_DEFINES) #List arguments (e.g. LANGUAGES C ASM CXX) |
| 228 | cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN}) |
| 229 | |
| 230 | if (NOT DEFINED _MY_PARAMS_NS_TARGET) |
| 231 | message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'NS_TARGET' missing.") |
| 232 | endif() |
| 233 | |
| 234 | if (NOT DEFINED _MY_PARAMS_S_TARGET) |
| 235 | message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'S_TARGET' missing.") |
| 236 | endif() |
| 237 | |
| 238 | if (NOT DEFINED _MY_PARAMS_FULL_BIN) |
| 239 | message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'FULL_BIN' missing.") |
| 240 | endif() |
| 241 | |
| 242 | if (NOT DEFINED _MY_PARAMS_SIGN_BIN) |
| 243 | message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'SIGN_BIN' missing.") |
| 244 | endif() |
| 245 | |
| 246 | if (NOT DEFINED _MY_PARAMS_VENEER_NAME) |
| 247 | message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'VENEER_NAME' missing.") |
| 248 | endif() |
| 249 | |
| 250 | set(EXE_NAME ${_MY_PARAMS_NS_TARGET}${_MY_PARAMS_POSTFIX}) |
| 251 | set(S_BIN ${_MY_PARAMS_S_TARGET}${_MY_PARAMS_POSTFIX}) |
| 252 | set(FULL_NAME ${_MY_PARAMS_FULL_BIN}${_MY_PARAMS_POSTFIX}) |
| 253 | set(SIGN_NAME ${_MY_PARAMS_SIGN_BIN}${_MY_PARAMS_POSTFIX}) |
| 254 | set(VENEER_NAME ${_MY_PARAMS_VENEER_NAME}${_MY_PARAMS_POSTFIX}.o) |
| 255 | |
| 256 | #Create linker target: add object library to executable |
| 257 | add_executable(${EXE_NAME} $<TARGET_OBJECTS:${PROJECT_OBJ_LIB}>) |
| 258 | |
| 259 | #Set common linker flags |
| 260 | config_setting_shared_linker_flags(${EXE_NAME}) |
| 261 | |
| 262 | #Set individual linker flags per linker target/executable |
| 263 | foreach(flag ${_MY_PARAMS_LINK_DEFINES}) |
| 264 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "${flag}") |
| 265 | endforeach(flag) |
| 266 | |
| 267 | embedded_set_target_linker_file(TARGET ${EXE_NAME} PATH "${NS_SCATTER_FILE_NAME}") |
| 268 | |
| 269 | #Add the RTX library |
| 270 | if(NOT DEFINED RTX_LIB_PATH) |
| 271 | message(FATAL_ERROR "ERROR: Incomplete Configuration: RTX_LIB_PATH is not defined.") |
| 272 | endif() |
| 273 | |
| 274 | #Add the PSA API compliance test libraries |
| 275 | if(PSA_API_TEST_NS) |
| 276 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/val/val_nspe.a") |
| 277 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/platform/pal_nspe.a") |
| 278 | endif() |
| 279 | if(PSA_API_TEST_NS AND (PSA_API_TEST_INTERNAL_TRUSTED_STORAGE OR PSA_API_TEST_PROTECTED_STORAGE OR PSA_API_TEST_STORAGE)) |
| 280 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/storage/test_combine.a") |
| 281 | endif() |
| 282 | if(PSA_API_TEST_NS AND PSA_API_TEST_CRYPTO) |
| 283 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/crypto/test_combine.a") |
| 284 | endif() |
| 285 | if(PSA_API_TEST_NS AND PSA_API_TEST_INITIAL_ATTESTATION) |
| 286 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/initial_attestation/test_combine.a") |
| 287 | endif() |
| 288 | if(PSA_API_TEST_NS AND PSA_API_TEST_IPC) |
| 289 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/ff/ipc/test_combine.a") |
| 290 | endif() |
| 291 | |
| 292 | if(NOT DEFINED PLATFORM_LINK_INCLUDES) |
| 293 | message(FATAL_ERROR "ERROR: Incomplete Configuration: PLATFORM_LINK_INCLUDES is not defined.") |
| 294 | endif() |
| 295 | embedded_set_target_link_includes(TARGET ${EXE_NAME} INCLUDES "${PLATFORM_LINK_INCLUDES}") |
| 296 | |
| 297 | #Generate binary file from axf |
| 298 | compiler_generate_binary_output(${EXE_NAME}) |
| 299 | |
| 300 | #Generate intel hex file from axf |
| 301 | compiler_generate_hex_output(${EXE_NAME}) |
| 302 | |
| 303 | #Generate elf file from axf |
| 304 | compiler_generate_elf_output(${EXE_NAME}) |
| 305 | |
| 306 | #Generate MCUBoot compatible payload |
| 307 | if (BL2) |
| 308 | mcuboot_create_boot_payload(S_BIN ${S_BIN} |
| 309 | NS_BIN ${EXE_NAME} |
| 310 | FULL_BIN ${FULL_NAME} |
| 311 | SIGN_BIN ${SIGN_NAME} |
| 312 | POSTFIX ${_MY_PARAMS_POSTFIX}) |
| 313 | endif() |
| 314 | |
| 315 | if (NOT DEFINED TFM_PARTITION_TEST_CORE) |
| 316 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_CORE is undefined. ") |
| 317 | elseif (TFM_PARTITION_TEST_CORE) |
| 318 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_CORE") |
| 319 | endif() |
| 320 | |
| 321 | if (NOT DEFINED TFM_PARTITION_TEST_CORE_IPC) |
| 322 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_CORE_IPC is undefined.") |
| 323 | elseif (TFM_PARTITION_TEST_CORE_IPC) |
| 324 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_CORE_IPC") |
| 325 | endif() |
| 326 | |
| 327 | if (NOT DEFINED TFM_PARTITION_TEST_SECURE_SERVICES) |
| 328 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_SECURE_SERVICES is undefined. ") |
| 329 | elseif (TFM_PARTITION_TEST_SECURE_SERVICES) |
| 330 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_SECURE_SERVICES") |
| 331 | endif() |
| 332 | |
| 333 | if (NOT DEFINED TEST_FRAMEWORK_S) |
| 334 | message(FATAL_ERROR "Incomplete build configuration: TEST_FRAMEWORK_S is undefined.") |
| 335 | elseif (TEST_FRAMEWORK_S) |
| 336 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TEST_FRAMEWORK_S") |
| 337 | endif() |
| 338 | |
| 339 | if (NOT DEFINED TEST_FRAMEWORK_NS) |
| 340 | message(FATAL_ERROR "Incomplete build configuration: TEST_FRAMEWORK_NS is undefined.") |
| 341 | elseif (TEST_FRAMEWORK_NS) |
| 342 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TEST_FRAMEWORK_NS") |
| 343 | endif() |
| 344 | |
| 345 | #Set BL2 specific settings. |
| 346 | if (BL2) |
| 347 | #Add BL2 and MCUBOOT_IMAGE_NUMBER defines to linker to resolve symbols in region_defs.h and flash_layout.h |
| 348 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "BL2" "MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER}") |
| 349 | endif() |
| 350 | |
| 351 | #We depend on the non secure tests. See if the library target is available. |
| 352 | if(TARGET tfm_non_secure_tests) |
| 353 | #If yes, then use the library. |
| 354 | target_link_libraries(${EXE_NAME} tfm_non_secure_tests) |
| 355 | #Ensure library is built first. |
| 356 | add_dependencies(${EXE_NAME} tfm_non_secure_tests) |
| 357 | endif() |
| 358 | |
| 359 | target_link_libraries(${EXE_NAME} "${RTX_LIB_PATH}") |
| 360 | |
| 361 | #Ensure secure_fw is built before our executable. |
| 362 | add_dependencies(${EXE_NAME} ${S_BIN}) |
| 363 | |
| 364 | if (NOT DEFINED TFM_MULTI_CORE_TOPOLOGY OR NOT TFM_MULTI_CORE_TOPOLOGY) |
| 365 | if (NOT DEFINED S_VENEER_PATH) |
| 366 | if (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/../secure_fw) |
| 367 | set (S_VENEER_PATH "${CMAKE_CURRENT_BINARY_DIR}/../secure_fw") |
| 368 | else() |
| 369 | message(FATAL_ERROR "No valid path for S_VENEER_PATH, secure_fw is built?") |
| 370 | endif() |
| 371 | endif() |
| 372 | |
| 373 | #Add the veneers to the executable. |
| 374 | set(S_VENEER_FILE "${S_VENEER_PATH}/${VENEER_NAME}") |
| 375 | set_property(TARGET ${EXE_NAME} APPEND PROPERTY LINK_LIBRARIES ${S_VENEER_FILE}) |
| 376 | endif() |
| 377 | |
| 378 | #Collect executables to common location: build/install/outputs/ |
| 379 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.axf |
| 380 | ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.bin |
| 381 | ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.hex |
| 382 | ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.elf |
| 383 | DESTINATION outputs/${TARGET_PLATFORM}/) |
| 384 | |
| 385 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.axf |
| 386 | ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.bin |
| 387 | ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.hex |
| 388 | ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.elf |
| 389 | DESTINATION outputs/fvp/) |
| 390 | endfunction() |
| 391 | |
| 392 | if (LINK_TO_BOTH_MEMORY_REGION) |
| 393 | #Link to primary memory region |
| 394 | set_up_app_build(NS_TARGET ${PROJECT_NAME} |
| 395 | S_TARGET tfm_s |
| 396 | FULL_BIN tfm_full |
| 397 | SIGN_BIN tfm_sign |
| 398 | VENEER_NAME s_veneers) |
| 399 | |
| 400 | #Link to secondary memory region(add extra linker flag) |
| 401 | set_up_app_build(NS_TARGET ${PROJECT_NAME} |
| 402 | LINK_DEFINES "LINK_TO_SECONDARY_PARTITION" |
| 403 | S_TARGET tfm_s |
| 404 | FULL_BIN tfm_full |
| 405 | SIGN_BIN tfm_sign |
| 406 | VENEER_NAME s_veneers |
| 407 | POSTFIX "_1") |
| 408 | else() |
| 409 | #Link to primary memory region only |
| 410 | set_up_app_build(NS_TARGET ${PROJECT_NAME} |
| 411 | S_TARGET tfm_s |
| 412 | FULL_BIN tfm_full |
| 413 | SIGN_BIN tfm_sign |
| 414 | VENEER_NAME s_veneers) |
| 415 | endif() |
| 416 | |
| 417 | #If the tfm_non_secure_tests target is not available |
| 418 | if(NOT TARGET tfm_non_secure_tests) |
| 419 | #Add the test source to the build. |
| 420 | #As of today since secure_fw is built as a sub-project this code will never execute. |
| 421 | option(ENABLE_PROTECTED_STORAGE_SERVICE_TESTS "" TRUE) |
| 422 | include(${TEST_DIR}/CMakeLists.inc) |
| 423 | target_sources(${PROJECT_OBJ_LIB} PUBLIC ${ALL_SRC_C} ${ALL_SRC_C_NS}) |
| 424 | endif() |
| 425 | |
| 426 | #Finally let CMake system apply changes after the whole project is defined. |
| 427 | if (TARGET ${PROJECT_NAME}) |
| 428 | embedded_project_end(${PROJECT_NAME}) |
| 429 | endif() |
| 430 | |
| 431 | if (TARGET ${PROJECT_NAME}_1) |
| 432 | embedded_project_end(${PROJECT_NAME}_1) |
| 433 | endif() |
| 434 | |
| 435 | embedded_project_end(${PROJECT_OBJ_LIB}) |