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