Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Jamie Fox | 17c30bb | 2019-01-10 13:39:33 +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 | |
| 16 | #Start an embedded project. |
| 17 | embedded_project_start(CONFIG "${CMAKE_CURRENT_LIST_DIR}/../ConfigDefault.cmake") |
| 18 | project(tfm_ns LANGUAGES ASM C) |
| 19 | embedded_project_fixup() |
| 20 | |
| 21 | set(APP_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 22 | get_filename_component(TFM_ROOT_DIR ${APP_DIR}/.. ABSOLUTE) |
| 23 | set(INTERFACE_DIR ${TFM_ROOT_DIR}/interface) |
Mate Toth-Pal | 813e9d1 | 2019-01-17 15:51:29 +0100 | [diff] [blame] | 24 | set(TEST_DIR ${TFM_ROOT_DIR}/test) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 25 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 26 | #Include BL2 bootloader related functions |
| 27 | set(MCUBOOT_DIR "${TFM_ROOT_DIR}/bl2/ext/mcuboot") |
| 28 | include("${MCUBOOT_DIR}/MCUBoot.cmake") |
| 29 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 30 | #Set variables |
| 31 | get_filename_component(CMSIS_5_DIR ${TFM_ROOT_DIR}/../CMSIS_5 ABSOLUTE) |
| 32 | |
| 33 | if(NOT EXISTS ${CMSIS_5_DIR}) |
| 34 | message(FATAL_ERROR "Missing CMSIS_5. Please clone the CMSIS_5 repo to directory \"${CMSIS_5_DIR}\".") |
| 35 | endif() |
| 36 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 37 | if (NOT DEFINED BL2) |
| 38 | message(FATAL_ERROR "Incomplete build configuration: BL2 is undefined. ") |
| 39 | endif () |
| 40 | |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 41 | if (NOT DEFINED TFM_PARTITION_AUDIT_LOG) |
| 42 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_AUDIT_LOG is undefined.") |
| 43 | endif() |
| 44 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 45 | set(NS_APP_SRC "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Config/RTX_Config.c" |
| 46 | "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Source/rtx_lib.c" |
| 47 | "${APP_DIR}/main_ns.c" |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 48 | "${APP_DIR}/tfm_integ_test.c" |
| 49 | "${APP_DIR}/os_wrapper_rtx.c" |
| 50 | "${INTERFACE_DIR}/src/tfm_sst_api.c" |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 51 | "${INTERFACE_DIR}/src/tfm_crypto_api.c" |
Marc Moreno Berengue | 8e0fa7a | 2018-10-04 18:25:13 +0100 | [diff] [blame] | 52 | "${INTERFACE_DIR}/src/tfm_platform_api.c" |
Tamas Ban | 48a0eb5 | 2018-08-17 12:48:05 +0100 | [diff] [blame] | 53 | "${INTERFACE_DIR}/src/tfm_initial_attestation_api.c" |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 54 | "${INTERFACE_DIR}/src/tfm_ns_lock_rtx.c" |
| 55 | ) |
| 56 | |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 57 | if (TFM_PARTITION_AUDIT_LOG) |
| 58 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_audit_api.c") |
| 59 | endif() |
| 60 | |
Miklos Balint | 16a9ffb | 2018-11-19 11:35:49 +0100 | [diff] [blame] | 61 | if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION) |
| 62 | message(FATAL_ERROR "Incomplete build configuration: TFM_NS_CLIENT_IDENTIFICATION is undefined.") |
| 63 | elseif (TFM_NS_CLIENT_IDENTIFICATION) |
| 64 | list(APPEND NS_APP_SRC |
| 65 | "${INTERFACE_DIR}/src/tfm_nspm_svc_handler.c" |
| 66 | "${INTERFACE_DIR}/src/tfm_nspm_api.c" |
| 67 | ) |
| 68 | endif() |
| 69 | |
Jamie Fox | 17c30bb | 2019-01-10 13:39:33 +0000 | [diff] [blame] | 70 | if (PSA_API_TEST_NS) |
| 71 | list(APPEND NS_APP_SRC "${APP_DIR}/psa_api_test.c") |
| 72 | endif() |
| 73 | |
Miklos Balint | 87da251 | 2018-04-19 13:45:50 +0200 | [diff] [blame] | 74 | if (NOT DEFINED TFM_PSA_API) |
| 75 | message(FATAL_ERROR "Incomplete build configuration: TFM_PSA_API is undefined. ") |
| 76 | elseif (TFM_PSA_API) |
| 77 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_psa_ns_api.c") |
| 78 | endif() |
| 79 | |
Marc Moreno Berengue | a1f296f | 2018-01-25 15:21:22 +0000 | [diff] [blame] | 80 | set(BUILD_CMSIS_CORE On) |
| 81 | set(BUILD_RETARGET On) |
| 82 | set(BUILD_NATIVE_DRIVERS On) |
| 83 | set(BUILD_TIME Off) |
| 84 | set(BUILD_STARTUP On) |
| 85 | set(BUILD_TARGET_CFG Off) |
| 86 | set(BUILD_TARGET_HARDWARE_KEYS Off) |
Marc Moreno Berengue | 4cc81fc | 2018-08-10 14:32:01 +0100 | [diff] [blame] | 87 | set(BUILD_TARGET_NV_COUNTERS Off) |
Marc Moreno Berengue | a1f296f | 2018-01-25 15:21:22 +0000 | [diff] [blame] | 88 | set(BUILD_CMSIS_DRIVERS On) |
| 89 | set(BUILD_UART_STDOUT Off) |
| 90 | set(BUILD_FLASH Off) |
Tamas Ban | 3681ce0 | 2018-11-22 15:19:24 +0000 | [diff] [blame] | 91 | set(BUILD_BOOT_SEED Off) |
Tamas Ban | 2318feb | 2019-01-02 16:50:51 +0000 | [diff] [blame] | 92 | set(BUILD_DEVICE_ID Off) |
Marc Moreno Berengue | a1f296f | 2018-01-25 15:21:22 +0000 | [diff] [blame] | 93 | if(NOT DEFINED PLATFORM_CMAKE_FILE) |
| 94 | message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.") |
| 95 | elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE}) |
| 96 | message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.") |
| 97 | else() |
| 98 | include(${PLATFORM_CMAKE_FILE}) |
| 99 | endif() |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 100 | |
Mate Toth-Pal | 48fc6a0 | 2018-01-24 09:50:14 +0100 | [diff] [blame] | 101 | if(NOT DEFINED NS_SCATTER_FILE_NAME) |
| 102 | message(FATAL_ERROR "ERROR: Incomplete Configuration: NS_SCATTER_FILE_NAME not defined, Include this file from a Config*.cmake") |
| 103 | endif() |
Gabor Kertesz | d7d7d74 | 2018-07-04 11:50:05 +0200 | [diff] [blame] | 104 | embedded_set_target_linker_file(TARGET ${PROJECT_NAME} PATH "${NS_SCATTER_FILE_NAME}") |
| 105 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 106 | #Create an object library to avoid compiling all source files twice, when two executables |
| 107 | #with different memory map need to be linked(BL2 non-swapping) |
| 108 | set(PROJECT_OBJ_LIB ${PROJECT_NAME}_obj_lib) |
| 109 | add_library(${PROJECT_OBJ_LIB} OBJECT ${ALL_SRC_C} ${ALL_SRC_C_NS} ${ALL_SRC_ASM_NS} ${NS_APP_SRC}) |
| 110 | |
| 111 | #Set common compiler flags |
| 112 | config_setting_shared_compiler_flags(${PROJECT_OBJ_LIB}) |
| 113 | |
| 114 | #Set macro definitions |
| 115 | target_compile_definitions(${PROJECT_OBJ_LIB} PRIVATE __thumb2__ __DOMAIN_NS=1 __ARM_FEATURE_CMSE=3 LOG_MSG_HANDLER_MODE_PRINTF_ENABLED) |
Mate Toth-Pal | 48fc6a0 | 2018-01-24 09:50:14 +0100 | [diff] [blame] | 116 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 117 | #Set include directories. |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 118 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TEST_INTERFACE_DIR}/include ABSOLUTE APPEND) |
| 119 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${INTERFACE_DIR}/include ABSOLUTE APPEND) |
| 120 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TFM_ROOT_DIR} ABSOLUTE APPEND) |
| 121 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TFM_ROOT_DIR}/secure_fw/spm ABSOLUTE APPEND) |
| 122 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TFM_ROOT_DIR}/secure_fw/core ABSOLUTE APPEND) |
| 123 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Include ABSOLUTE APPEND) |
| 124 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${CMSIS_5_DIR}/CMSIS/RTOS2/Include ABSOLUTE APPEND) |
| 125 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Config ABSOLUTE APPEND) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 126 | |
| 127 | if (NOT DEFINED CORE_TEST) |
| 128 | message(FATAL_ERROR "Incomplete build configuration: CORE_TEST is undefined. ") |
| 129 | elseif(CORE_TEST) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 130 | target_compile_definitions(${PROJECT_OBJ_LIB} PRIVATE CORE_TEST) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 131 | endif() |
| 132 | |
Mate Toth-Pal | 5313609 | 2018-09-19 09:34:01 +0200 | [diff] [blame] | 133 | if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION) |
| 134 | message(FATAL_ERROR "Incomplete build configuration: TFM_NS_CLIENT_IDENTIFICATION is undefined.") |
| 135 | elseif (TFM_NS_CLIENT_IDENTIFICATION) |
| 136 | target_compile_definitions(${PROJECT_OBJ_LIB} PRIVATE TFM_NS_CLIENT_IDENTIFICATION) |
| 137 | endif() |
| 138 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 139 | # For the non-swapping BL2 configuration two executables need to be built. |
| 140 | # One can be executed from flash partition slot_0 and other from slot_1. |
| 141 | # Only the linking phase is different. This function captures common settings |
| 142 | # and eliminates copy-paste. |
| 143 | function(set_up_app_build) |
| 144 | set( _OPTIONS_ARGS) #Option (on/off) arguments (e.g. IGNORE_CASE) |
| 145 | set( _ONE_VALUE_ARGS NS_TARGET S_TARGET FULL_BIN SIGN_BIN VENEER_NAME POSTFIX) #Single option arguments (e.g. PATH "./foo/bar") |
| 146 | set( _MULTI_VALUE_ARGS LINK_DEFINES) #List arguments (e.g. LANGUAGES C ASM CXX) |
| 147 | cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN}) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 148 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 149 | if (NOT DEFINED _MY_PARAMS_NS_TARGET) |
| 150 | message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'NS_TARGET' missing.") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 151 | endif() |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 152 | |
| 153 | if (NOT DEFINED _MY_PARAMS_S_TARGET) |
| 154 | message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'S_TARGET' missing.") |
| 155 | endif() |
| 156 | |
| 157 | if (NOT DEFINED _MY_PARAMS_FULL_BIN) |
| 158 | message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'FULL_BIN' missing.") |
| 159 | endif() |
| 160 | |
| 161 | if (NOT DEFINED _MY_PARAMS_SIGN_BIN) |
| 162 | message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'SIGN_BIN' missing.") |
| 163 | endif() |
| 164 | |
| 165 | if (NOT DEFINED _MY_PARAMS_VENEER_NAME) |
| 166 | message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'VENEER_NAME' missing.") |
| 167 | endif() |
| 168 | |
| 169 | set(EXE_NAME ${_MY_PARAMS_NS_TARGET}${_MY_PARAMS_POSTFIX}) |
| 170 | set(S_BIN ${_MY_PARAMS_S_TARGET}${_MY_PARAMS_POSTFIX}) |
| 171 | set(FULL_NAME ${_MY_PARAMS_FULL_BIN}${_MY_PARAMS_POSTFIX}) |
| 172 | set(SIGN_NAME ${_MY_PARAMS_SIGN_BIN}${_MY_PARAMS_POSTFIX}) |
| 173 | set(VENEER_NAME ${_MY_PARAMS_VENEER_NAME}${_MY_PARAMS_POSTFIX}.o) |
| 174 | |
| 175 | #Create linker target: add object library to executable |
Tamas Ban | a4574d9 | 2019-03-06 14:21:33 +0000 | [diff] [blame] | 176 | add_executable(${EXE_NAME} $<TARGET_OBJECTS:${PROJECT_OBJ_LIB}>) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 177 | |
| 178 | #Set common linker flags |
| 179 | config_setting_shared_linker_flags(${EXE_NAME}) |
| 180 | |
| 181 | #Set individual linker flags per linker target/executable |
| 182 | foreach(flag ${_MY_PARAMS_LINK_DEFINES}) |
| 183 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "${flag}") |
| 184 | endforeach(flag) |
| 185 | |
| 186 | embedded_set_target_linker_file(TARGET ${EXE_NAME} PATH "${NS_SCATTER_FILE_NAME}") |
| 187 | |
| 188 | #Add the RTX library |
| 189 | if(NOT DEFINED RTX_LIB_PATH) |
| 190 | message(FATAL_ERROR "ERROR: Incomplete Configuration: RTX_LIB_PATH is not defined.") |
| 191 | endif() |
| 192 | target_link_libraries(${EXE_NAME} "${RTX_LIB_PATH}") |
| 193 | |
Jamie Fox | 17c30bb | 2019-01-10 13:39:33 +0000 | [diff] [blame] | 194 | #Add the PSA API compliance test libraries |
| 195 | if(NOT DEFINED PSA_API_TEST_BUILD_PATH) |
| 196 | #If not specified, assume it's the default build folder checked out at the same level of TFM root dir |
| 197 | set(PSA_API_TEST_BUILD_PATH "${TFM_ROOT_DIR}/../psa-arch-tests/api-tests/BUILD") |
| 198 | endif() |
| 199 | if(PSA_API_TEST_NS) |
| 200 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/val/val_nspe.a") |
| 201 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/platform/pal_nspe.a") |
| 202 | endif() |
| 203 | if(PSA_API_TEST_NS AND PSA_API_TEST_SECURE_STORAGE) |
| 204 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/protected_storage/test_combine.a") |
| 205 | endif() |
| 206 | if(PSA_API_TEST_NS AND PSA_API_TEST_CRYPTO) |
| 207 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/crypto/test_combine.a") |
| 208 | endif() |
| 209 | if(PSA_API_TEST_NS AND PSA_API_TEST_ATTESTATION) |
| 210 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/initial_attestation/test_combine.a") |
| 211 | endif() |
| 212 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 213 | if(NOT DEFINED PLATFORM_LINK_INCLUDES) |
| 214 | message(FATAL_ERROR "ERROR: Incomplete Configuration: PLATFORM_LINK_INCLUDES is not defined.") |
| 215 | endif() |
| 216 | embedded_set_target_link_includes(TARGET ${EXE_NAME} INCLUDES "${PLATFORM_LINK_INCLUDES}") |
| 217 | |
| 218 | #Generate binary file from axf |
| 219 | compiler_generate_binary_output(${EXE_NAME}) |
| 220 | |
| 221 | #Generate MCUBoot compatible payload |
| 222 | if (BL2) |
| 223 | mcuboot_create_boot_payload(S_BIN ${S_BIN} |
| 224 | NS_BIN ${EXE_NAME} |
| 225 | FULL_BIN ${FULL_NAME} |
| 226 | SIGN_BIN ${SIGN_NAME} |
| 227 | POSTFIX ${_MY_PARAMS_POSTFIX}) |
| 228 | endif() |
| 229 | |
| 230 | if (NOT DEFINED TFM_PARTITION_TEST_CORE) |
| 231 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_CORE is undefined. ") |
| 232 | elseif (TFM_PARTITION_TEST_CORE) |
| 233 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_CORE") |
| 234 | endif() |
| 235 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 236 | if (NOT DEFINED TFM_PARTITION_TEST_SECURE_SERVICES) |
| 237 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_SECURE_SERVICES is undefined. ") |
| 238 | elseif (TFM_PARTITION_TEST_SECURE_SERVICES) |
| 239 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_SECURE_SERVICES") |
| 240 | endif() |
| 241 | |
Marc Moreno Berengue | cae2c53 | 2018-10-09 12:58:46 +0100 | [diff] [blame] | 242 | if (NOT DEFINED TEST_FRAMEWORK_S) |
| 243 | message(FATAL_ERROR "Incomplete build configuration: TEST_FRAMEWORK_S is undefined.") |
| 244 | elseif (TEST_FRAMEWORK_S) |
| 245 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TEST_FRAMEWORK_S") |
| 246 | endif() |
| 247 | |
| 248 | if (NOT DEFINED TEST_FRAMEWORK_NS) |
| 249 | message(FATAL_ERROR "Incomplete build configuration: TEST_FRAMEWORK_NS is undefined.") |
| 250 | elseif (TEST_FRAMEWORK_NS) |
| 251 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TEST_FRAMEWORK_NS") |
| 252 | endif() |
| 253 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 254 | #Set BL2 specific settings. |
| 255 | if (BL2) |
| 256 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "BL2") |
| 257 | endif() |
| 258 | |
| 259 | #We depend on the non secure tests. See if the library target is available. |
| 260 | if(TARGET tfm_non_secure_tests) |
| 261 | #If yes, then use the library. |
| 262 | target_link_libraries(${EXE_NAME} tfm_non_secure_tests) |
| 263 | #Ensure library is built first. |
| 264 | add_dependencies(${EXE_NAME} tfm_non_secure_tests) |
| 265 | endif() |
| 266 | |
| 267 | #Ensure secure_fw is built before our executable. |
| 268 | add_dependencies(${EXE_NAME} ${S_BIN}) |
| 269 | |
| 270 | #Add the veneers to the executable. |
| 271 | set(S_VENEER_FILE "${CMAKE_CURRENT_BINARY_DIR}/${VENEER_NAME}") |
| 272 | set_property(TARGET ${EXE_NAME} APPEND PROPERTY LINK_LIBRARIES ${S_VENEER_FILE}) |
| 273 | |
| 274 | #Collect executables to common location: build/install/outputs/ |
| 275 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.axf |
| 276 | ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.bin |
| 277 | DESTINATION outputs/${TARGET_PLATFORM}/) |
| 278 | |
| 279 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.axf |
| 280 | ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.bin |
| 281 | DESTINATION outputs/fvp/) |
| 282 | endfunction() |
| 283 | |
| 284 | if (NOT TARGET_TFM_S_EXISTED) |
| 285 | set(S_VENEER_FILE_LOCATION "${CMAKE_CURRENT_BINARY_DIR}") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 286 | add_subdirectory(../secure_fw ${CMAKE_CURRENT_BINARY_DIR}/secure_fw) |
| 287 | endif() |
| 288 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 289 | if (LINK_TO_BOTH_MEMORY_REGION) |
| 290 | #Link to primary memory region |
| 291 | set_up_app_build(NS_TARGET ${PROJECT_NAME} |
| 292 | S_TARGET tfm_s |
| 293 | FULL_BIN tfm_full |
| 294 | SIGN_BIN tfm_sign |
| 295 | VENEER_NAME s_veneers |
Tamas Ban | 57bfa43 | 2018-04-13 16:05:49 +0100 | [diff] [blame] | 296 | POSTFIX "_0") |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 297 | |
| 298 | #Link to secondary memory region(add extra linker flag) |
Oliver Swede | 2144044 | 2018-07-10 09:31:32 +0100 | [diff] [blame] | 299 | set_up_app_build(NS_TARGET ${PROJECT_NAME} |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 300 | LINK_DEFINES "LINK_TO_SECONDARY_PARTITION" |
| 301 | S_TARGET tfm_s |
| 302 | FULL_BIN tfm_full |
| 303 | SIGN_BIN tfm_sign |
| 304 | VENEER_NAME s_veneers |
Tamas Ban | 57bfa43 | 2018-04-13 16:05:49 +0100 | [diff] [blame] | 305 | POSTFIX "_1") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 306 | else() |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 307 | #Link to primary memory region only |
Oliver Swede | 2144044 | 2018-07-10 09:31:32 +0100 | [diff] [blame] | 308 | set_up_app_build(NS_TARGET ${PROJECT_NAME} |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 309 | S_TARGET tfm_s |
| 310 | FULL_BIN tfm_full |
| 311 | SIGN_BIN tfm_sign |
| 312 | VENEER_NAME s_veneers) |
| 313 | endif() |
| 314 | |
| 315 | #If the tfm_non_secure_tests target is not available |
| 316 | if(NOT TARGET tfm_non_secure_tests) |
| 317 | #Add the test source to the build. |
| 318 | #As of today since secure_fw is built as a sub-project this code will never execute. |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 319 | option(ENABLE_INVERT_SERVICE_TESTS "" TRUE) |
| 320 | option(ENABLE_SECURE_STORAGE_SERVICE_TESTS "" TRUE) |
| 321 | include(../test/CMakeLists.inc) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 322 | target_sources(${PROJECT_OBJ_LIB} PUBLIC ${ALL_SRC_C} ${ALL_SRC_C_NS}) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 323 | endif() |
| 324 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 325 | #Finally let CMake system apply changes after the whole project is defined. |
| 326 | if (TARGET ${PROJECT_NAME}) |
| 327 | embedded_project_end(${PROJECT_NAME}) |
| 328 | endif() |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 329 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 330 | if (TARGET ${PROJECT_NAME}_0) |
| 331 | embedded_project_end(${PROJECT_NAME}_0) |
| 332 | endif() |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 333 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 334 | if (TARGET ${PROJECT_NAME}_1) |
| 335 | embedded_project_end(${PROJECT_NAME}_1) |
| 336 | endif() |
| 337 | |
| 338 | embedded_project_end(${PROJECT_OBJ_LIB}) |