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