aboutsummaryrefslogtreecommitdiff
path: root/secure_fw/CMakeLists.txt
blob: e71971ec2e858e31c592c56c83b8b51fc1252130 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
#-------------------------------------------------------------------------------
# Copyright (c) 2017-2020, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
#-------------------------------------------------------------------------------

cmake_minimum_required(VERSION 3.7)

set(TFM_BUILD_IN_SPE ON)

#Tell cmake where our modules can be found
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake)

set(SECURE_FW_DIR "${CMAKE_CURRENT_LIST_DIR}")
set(TFM_ROOT_DIR  "${SECURE_FW_DIR}/..")
set(TEST_DIR      "${TFM_ROOT_DIR}/test")
set(INTERFACE_DIR "${TFM_ROOT_DIR}/interface")

#Include common stuff to control cmake.
include("Common/BuildSys")

#Start an embedded project.
embedded_project_start(CONFIG "${TFM_ROOT_DIR}/configs/ConfigDefault.cmake")
project(tfm_s LANGUAGES ASM C)
embedded_project_fixup()

#Include functionality to enable building the documentation.
include("Common/BuildDoxygenDoc")
include("Common/BuildSphinxDoc")

if (NOT DEFINED TFM_LVL)
	message(FATAL_ERROR "Incomplete build configuration: TFM_LVL is undefined. ")
endif()

if (NOT DEFINED TFM_PARTITION_AUDIT_LOG)
	message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_AUDIT_LOG is undefined.")
endif()

if (NOT DEFINED TFM_PARTITION_PLATFORM)
	message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_PLATFORM is undefined.")
endif()

if (NOT DEFINED TFM_PARTITION_SECURE_STORAGE)
	message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_SECURE_STORAGE is undefined.")
endif()

if (NOT DEFINED TFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
	message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_INTERNAL_TRUSTED_STORAGE is undefined.")
endif()

if (NOT DEFINED TFM_PARTITION_CRYPTO)
	message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_CRYPTO is undefined.")
endif()

if (NOT DEFINED TFM_PARTITION_INITIAL_ATTESTATION)
	message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_INITIAL_ATTESTATION is undefined.")
endif()

if (NOT DEFINED TFM_PARTITION_TEST_CORE)
	message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_CORE is undefined. ")
endif()

if (NOT DEFINED TFM_PARTITION_TEST_CORE_IPC)
	message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_CORE_IPC is undefined.")
endif()

if (NOT DEFINED TFM_PARTITION_TEST_SECURE_SERVICES)
	message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_SECURE_SERVICES is undefined. ")
endif()

if (NOT DEFINED TFM_PARTITION_TEST_SST)
	message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_SST is undefined.")
endif()

if (NOT DEFINED TEST_FRAMEWORK_S)
	message(FATAL_ERROR "Incomplete build configuration: TEST_FRAMEWORK_S is undefined.")
endif()

if (NOT DEFINED TEST_FRAMEWORK_NS)
	message(FATAL_ERROR "Incomplete build configuration: TEST_FRAMEWORK_NS is undefined.")
endif()

if (NOT DEFINED BL2)
	message(FATAL_ERROR "Incomplete build configuration: BL2 is undefined. ")
endif()

if (NOT DEFINED TFM_PSA_API)
	message(FATAL_ERROR "Incomplete build configuration: TFM_PSA_API is undefined. ")
endif()

if(NOT DEFINED PLATFORM_LINK_INCLUDES)
	message(FATAL_ERROR "ERROR: Incomplete Configuration: PLATFORM_LINK_INCLUDES is not defined.")
endif()

if (NOT DEFINED TFM_ENABLE_IRQ_TEST)
	message(FATAL_ERROR "ERROR: Incomplete Configuration: TFM_ENABLE_IRQ_TEST is not defined.")
endif()

include(${SECURE_FW_DIR}/spm/CMakeLists.inc)
if (NOT DEFINED TFM_MULTI_CORE_TOPOLOGY OR NOT TFM_MULTI_CORE_TOPOLOGY)
	include(${SECURE_FW_DIR}/ns_callable/CMakeLists.inc)
endif ()
#Involve all IPC related sources in ipc's CMakeLists.inc, and switch core between IPC and Library.
if(TFM_PSA_API)
	include(${SECURE_FW_DIR}/core/ipc/CMakeLists.inc)
else()
	include(${SECURE_FW_DIR}/core/CMakeLists.inc)
endif()
include(${SECURE_FW_DIR}/core/arch/CMakeLists.inc)

set(BUILD_CMSIS_CORE On)
set(BUILD_RETARGET On)
set(BUILD_NATIVE_DRIVERS On)
set(BUILD_STARTUP On)
set(BUILD_TARGET_CFG On)
# FIXME: The following TARGET flags are platform dependent.
#        It is required to add a mechanism to expose the
#        target capabilities and, based on them, set the
#        flags properly.
set(BUILD_TARGET_HARDWARE_KEYS On)
set(BUILD_TARGET_NV_COUNTERS On)
set(BUILD_CMSIS_DRIVERS On)
set(BUILD_TIME Off)
set(BUILD_UART_STDOUT On)
set(BUILD_FLASH On)
set(BUILD_PLAT_TEST Off)
if(NOT DEFINED PLATFORM_CMAKE_FILE)
	message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
	message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.")
else()
	include(${PLATFORM_CMAKE_FILE})
endif()

if(NOT DEFINED S_SCATTER_FILE_NAME)
	message(FATAL_ERROR "ERROR: Incomplete Configuration: S_SCATTER_FILE_NAME not defined, Include this file from a Config*.cmake")
endif()
embedded_set_target_linker_file(TARGET ${PROJECT_NAME} PATH "${S_SCATTER_FILE_NAME}")

embedded_target_include_directories(TARGET ${PROJECT_NAME} PATH ${TFM_ROOT_DIR} ABSOLUTE APPEND)
#Create an object library to avoid compiling all source files twice, when two executables
#with different memory map need to be linked(BL2 non-swapping)
set(PROJECT_OBJ_LIB ${PROJECT_NAME}_obj_lib)
add_library(${PROJECT_OBJ_LIB} OBJECT ${ALL_SRC_C} ${ALL_SRC_C_S} ${ALL_SRC_ASM} ${ALL_SRC_ASM_S})

#Add platform specific definitions in SPE
if (DEFINED TFM_PLATFORM_SECURE_DEFS)
	embedded_set_target_compile_defines(TARGET ${PROJECT_OBJ_LIB} LANGUAGE C DEFINES ${TFM_PLATFORM_SECURE_DEFS} APPEND)
	embedded_set_target_compile_defines(TARGET ${PROJECT_OBJ_LIB} LANGUAGE ASM DEFINES ${TFM_PLATFORM_SECURE_DEFS} APPEND)
endif()

#Set common compiler flags
config_setting_shared_compiler_flags(${PROJECT_OBJ_LIB})

if(NOT DEFINED TARGET_NV_COUNTERS_ENABLE)
	set(TARGET_NV_COUNTERS_ENABLE OFF)
endif()

if(TARGET_NV_COUNTERS_ENABLE)
	embedded_set_target_compile_defines(TARGET ${PROJECT_OBJ_LIB} LANGUAGE C DEFINES TFM_NVCOUNTERS_ENABLE APPEND)
endif()

if (NOT DEFINED CORE_TEST)
	message(FATAL_ERROR "Incomplete build configuration: CORE_TEST is undefined.")
elseif(CORE_TEST)
	embedded_set_target_compile_defines(TARGET ${PROJECT_OBJ_LIB} LANGUAGE C DEFINES TFM_CORE_DEBUG APPEND)
endif()

if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION)
	message(FATAL_ERROR "Incomplete build configuration: TFM_NS_CLIENT_IDENTIFICATION is undefined.")
elseif (TFM_NS_CLIENT_IDENTIFICATION)
	target_compile_definitions(${PROJECT_OBJ_LIB} PRIVATE TFM_NS_CLIENT_IDENTIFICATION)
endif()

if (NOT DEFINED DEBUG_AUTHENTICATION)
	set(DEBUG_AUTHENTICATION "DAUTH_CHIP_DEFAULT")
endif()

#Set include directories
embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TFM_ROOT_DIR} ABSOLUTE APPEND)

# For the non-swapping BL2 configuration two executables need to be built.
# One can be executed from the primary slot flash partition and other from the
# the secondary slot. Only the linking phase is different. This function
# captures common settings and eliminates copy-paste.
function(set_up_secure_fw_build)
	set( _OPTIONS_ARGS)                                #Option (on/off) arguments (e.g. IGNORE_CASE)
	set( _ONE_VALUE_ARGS S_TARGET VENEER_NAME POSTFIX) #Single option arguments (e.g. PATH "./foo/bar")
	set( _MULTI_VALUE_ARGS LINK_DEFINES)               #List arguments (e.g. LANGUAGES C ASM CXX)
	cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN})

	if (NOT DEFINED _MY_PARAMS_S_TARGET)
		message(FATAL_ERROR "set_up_secure_fw_build(): mandatory parameter 'S_TARGET' missing.")
	endif()

	if (NOT DEFINED _MY_PARAMS_VENEER_NAME)
		message(FATAL_ERROR "set_up_secure_fw_build(): mandatory parameter 'VENEER_NAME' missing.")
	endif()

	set(EXE_NAME ${_MY_PARAMS_S_TARGET}${_MY_PARAMS_POSTFIX})
	set(VENEER_NAME ${_MY_PARAMS_VENEER_NAME}${_MY_PARAMS_POSTFIX}.o)

	#Create linker target: add object library to executable
	add_executable(${EXE_NAME} $<TARGET_OBJECTS:${PROJECT_OBJ_LIB}>)

	#Set common linker flags
	config_setting_shared_linker_flags(${EXE_NAME})

	#Set individual linker flags per linker target/executable
	foreach(flag ${_MY_PARAMS_LINK_DEFINES})
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "${flag}")
	endforeach(flag)

	embedded_set_target_linker_file(TARGET ${EXE_NAME} PATH "${S_SCATTER_FILE_NAME}")

	#Set macro definitions for the project.
	set(TARGET_COMPILE_DEFINITIONS __thumb2__ __DOMAIN_NS=0 DOMAIN_NS=__DOMAIN_NS __ARM_FEATURE_CMSE=${ARM_FEATURE_CMSE} TFM_LVL=${TFM_LVL} ${DEBUG_AUTHENTICATION})
	embedded_set_target_compile_defines(TARGET ${PROJECT_OBJ_LIB} LANGUAGE C DEFINES ${TARGET_COMPILE_DEFINITIONS} APPEND)

	# The order of the libraries linked below is important for GCC
	# Because the GCC linker will search an archive only once.
	# If the a library has some symbols that are defined in the library which is linked before it,
	# it will not cause the linker to search again.
	# So please put a library before what it relies on.
	if (CORE_TEST OR TFM_PARTITION_TEST_SECURE_SERVICES)
		target_link_libraries(${EXE_NAME} tfm_secure_tests)
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_SECURE_SERVICES")
	endif()

	if (TFM_PARTITION_INITIAL_ATTESTATION)
		target_link_libraries(${EXE_NAME} tfm_attest)
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_INITIAL_ATTESTATION")
	endif()

	if (TFM_PARTITION_SECURE_STORAGE)
		target_link_libraries(${EXE_NAME} tfm_storage)
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_SECURE_STORAGE")
	endif()

	if (TFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
		target_link_libraries(${EXE_NAME} tfm_internal_trusted_storage)
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_INTERNAL_TRUSTED_STORAGE")
	endif()

	if (TFM_PARTITION_CRYPTO)
		target_link_libraries(${EXE_NAME} tfm_crypto)
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_CRYPTO")
	endif()

	if (TFM_PARTITION_AUDIT_LOG)
		target_link_libraries(${EXE_NAME} tfm_audit)
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_AUDIT_LOG")
	endif()

	if (TFM_PARTITION_PLATFORM)
		target_link_libraries(${EXE_NAME} tfm_platform)
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_PLATFORM")
	endif()

	target_link_libraries(${EXE_NAME} libtfmsprt)

	embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_LVL=${TFM_LVL}")

	if (TFM_PARTITION_TEST_CORE)
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_CORE")
	endif()

	if (TFM_PARTITION_TEST_CORE_IPC)
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_CORE_IPC")
	endif()

	if (TFM_PARTITION_TEST_SST)
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_SST")
	endif()

	if (TEST_FRAMEWORK_S)
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TEST_FRAMEWORK_S")
	endif()

	if (TEST_FRAMEWORK_NS)
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TEST_FRAMEWORK_NS")
	endif()

	if (BL2)
		#Add BL2 and MCUBOOT_IMAGE_NUMBER defines to linker to resolve symbols in region_defs.h and flash_layout.h
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "BL2" "MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER}")
	endif()

	if (TFM_PSA_API)
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PSA_API")
		if (DEFINED TFM_MULTI_CORE_TOPOLOGY AND TFM_MULTI_CORE_TOPOLOGY)
			embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_MULTI_CORE_TOPOLOGY")
		endif()
	endif()

	if(CORE_TEST)
		set(SECURE_AXF_DIR_PREFIX "${CMAKE_BINARY_DIR}/unit_test/")
		set_target_properties(${EXE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${SECURE_AXF_DIR_PREFIX})
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_CORE")
	endif()

	embedded_set_target_link_includes(TARGET ${EXE_NAME} INCLUDES "${PLATFORM_LINK_INCLUDES}")

	if (TFM_ENABLE_IRQ_TEST)
		embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_ENABLE_IRQ_TEST")
	endif()

	#Generate binary file from executable
	compiler_generate_binary_output(${EXE_NAME})

	if (NOT DEFINED TFM_MULTI_CORE_TOPOLOGY OR NOT TFM_MULTI_CORE_TOPOLOGY)
		#Configure where we put the CMSE veneers generated by the compiler.
		set(S_VENEER_FILE "${CMAKE_CURRENT_BINARY_DIR}/${VENEER_NAME}")
		compiler_set_cmse_output(${EXE_NAME} "${S_VENEER_FILE}")
	endif()

	#Configure what file shall be installed.
	#Set install location. Keep original value to avoid overriding command line settings.
	if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
		set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Default install location for secure_fw." FORCE)
	endif()

	#Export files needed to interface external applications at: <build_dir>/install/export/tfm/
	set(INTERFACE_INC_DIR "${INTERFACE_DIR}/include")
	set(INTERFACE_SRC_DIR "${INTERFACE_DIR}/src")
	set(EXPORT_INC_DIR "export/tfm/include")
	set(EXPORT_SRC_DIR "export/tfm/src")
	#Headers
	install(FILES       ${INTERFACE_INC_DIR}/psa/client.h
						${INTERFACE_INC_DIR}/psa/error.h
			DESTINATION ${EXPORT_INC_DIR}/psa)

	install(FILES       ${INTERFACE_INC_DIR}/os_wrapper/common.h
						${INTERFACE_INC_DIR}/os_wrapper/mutex.h
			DESTINATION ${EXPORT_INC_DIR}/os_wrapper)

	install(FILES       ${INTERFACE_INC_DIR}/psa_manifest/sid.h
			DESTINATION ${EXPORT_INC_DIR}/psa_manifest)

	install(FILES       ${INTERFACE_INC_DIR}/tfm_api.h
						${INTERFACE_INC_DIR}/tfm_ns_interface.h
						${INTERFACE_INC_DIR}/tfm_nspm_api.h
						${INTERFACE_INC_DIR}/tfm_nspm_svc_handler.h
						${INTERFACE_INC_DIR}/tfm_ns_svc.h
			DESTINATION ${EXPORT_INC_DIR})

	if (TFM_MULTI_CORE_TOPOLOGY)
		install(FILES       ${INTERFACE_INC_DIR}/tfm_multi_core_api.h
							${INTERFACE_INC_DIR}/tfm_ns_mailbox.h
							${INTERFACE_INC_DIR}/tfm_mailbox.h
				DESTINATION ${EXPORT_INC_DIR})
	else()
		install(FILES       ${INTERFACE_INC_DIR}/tfm_veneers.h
				DESTINATION ${EXPORT_INC_DIR})
	endif()

	#Sources
	install(FILES       ${INTERFACE_SRC_DIR}/tfm_nspm_api.c
						${INTERFACE_SRC_DIR}/tfm_nspm_svc_handler.c
			DESTINATION ${EXPORT_SRC_DIR})

	if (TFM_MULTI_CORE_TOPOLOGY)
		install(FILES       ${INTERFACE_SRC_DIR}/tfm_ns_mailbox.c
							${INTERFACE_SRC_DIR}/tfm_multi_core_api.c
							${INTERFACE_SRC_DIR}/tfm_multi_core_psa_ns_api.c
				DESTINATION ${EXPORT_SRC_DIR})
	else()
		install(FILES       ${INTERFACE_SRC_DIR}/tfm_ns_interface.c
				DESTINATION ${EXPORT_SRC_DIR})

		if(TFM_PSA_API)
			install(FILES       ${INTERFACE_SRC_DIR}/tfm_psa_ns_api.c
					DESTINATION ${EXPORT_SRC_DIR})
		endif()
	endif()

	if (TFM_PARTITION_SECURE_STORAGE)
		install(FILES       ${INTERFACE_INC_DIR}/psa/protected_storage.h
				DESTINATION ${EXPORT_INC_DIR}/psa)
		if (TFM_PSA_API)
			install(FILES       ${INTERFACE_SRC_DIR}/tfm_sst_ipc_api.c
					DESTINATION ${EXPORT_SRC_DIR})
		else()
			install(FILES       ${INTERFACE_SRC_DIR}/tfm_sst_func_api.c
					DESTINATION ${EXPORT_SRC_DIR})
		endif()
	endif()

	if (TFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
		install(FILES       ${INTERFACE_INC_DIR}/psa/internal_trusted_storage.h
							${INTERFACE_INC_DIR}/psa/storage_common.h
				DESTINATION ${EXPORT_INC_DIR}/psa)
		if (TFM_PSA_API)
			install(FILES       ${INTERFACE_SRC_DIR}/tfm_its_ipc_api.c
					DESTINATION ${EXPORT_SRC_DIR})
		else()
			install(FILES       ${INTERFACE_SRC_DIR}/tfm_its_func_api.c
					DESTINATION ${EXPORT_SRC_DIR})
		endif()
	endif()

	if (TFM_PARTITION_CRYPTO)
		install(FILES       ${INTERFACE_INC_DIR}/psa/crypto_extra.h
							${INTERFACE_INC_DIR}/psa/crypto.h
							${INTERFACE_INC_DIR}/psa/crypto_platform.h
							${INTERFACE_INC_DIR}/psa/crypto_sizes.h
							${INTERFACE_INC_DIR}/psa/crypto_struct.h
							${INTERFACE_INC_DIR}/psa/crypto_types.h
							${INTERFACE_INC_DIR}/psa/crypto_values.h
							${INTERFACE_INC_DIR}/tfm_crypto_defs.h
				DESTINATION ${EXPORT_INC_DIR}/psa)
		if (TFM_PSA_API)
			install(FILES       ${INTERFACE_SRC_DIR}/tfm_crypto_ipc_api.c
					DESTINATION ${EXPORT_SRC_DIR})
		else()
			install(FILES       ${INTERFACE_SRC_DIR}/tfm_crypto_func_api.c
					DESTINATION ${EXPORT_SRC_DIR})
		endif()
	endif()

	if (TFM_PARTITION_INITIAL_ATTESTATION)
		install(FILES       ${INTERFACE_INC_DIR}/psa/initial_attestation.h
				DESTINATION ${EXPORT_INC_DIR}/psa)
		if (TFM_PSA_API)
			install(FILES       ${INTERFACE_SRC_DIR}/tfm_initial_attestation_ipc_api.c
					DESTINATION ${EXPORT_SRC_DIR})
		else()
			install(FILES       ${INTERFACE_SRC_DIR}/tfm_initial_attestation_func_api.c
					DESTINATION ${EXPORT_SRC_DIR})
		endif()
	endif()

	if(TFM_PARTITION_AUDIT_LOG)
		install(FILES       ${INTERFACE_INC_DIR}/psa_audit_api.h
							${INTERFACE_INC_DIR}/psa_audit_defs.h
				DESTINATION ${EXPORT_INC_DIR})
		install(FILES       ${INTERFACE_SRC_DIR}/tfm_audit_func_api.c
				DESTINATION ${EXPORT_SRC_DIR})
	endif()

	if(TFM_PARTITION_PLATFORM)
		install(FILES       ${INTERFACE_INC_DIR}/tfm_platform_api.h
				DESTINATION ${EXPORT_INC_DIR})
		if(TFM_PSA_API)
			install(FILES       ${INTERFACE_SRC_DIR}/tfm_platform_ipc_api.c
					DESTINATION ${EXPORT_SRC_DIR})
		else()
			install(FILES       ${INTERFACE_SRC_DIR}/tfm_platform_func_api.c
					DESTINATION ${EXPORT_SRC_DIR})
		endif()
	endif()

	if (NOT DEFINED TFM_MULTI_CORE_TOPOLOGY OR NOT TFM_MULTI_CORE_TOPOLOGY)
		install(FILES ${S_VENEER_FILE} DESTINATION export/tfm/veneers)
	endif()

	#Collect executables to common location: <build_dir>/install/outputs/
	if (DEFINED SECURE_AXF_DIR_PREFIX)
		set(MY_BINARY_DIR ${SECURE_AXF_DIR_PREFIX})
	else()
		set(MY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
	endif()

	install(FILES ${MY_BINARY_DIR}/${EXE_NAME}.axf
				  ${MY_BINARY_DIR}/${EXE_NAME}.bin
			DESTINATION outputs/${TARGET_PLATFORM}/)

	install(FILES ${MY_BINARY_DIR}/${EXE_NAME}.axf
				  ${MY_BINARY_DIR}/${EXE_NAME}.bin
			DESTINATION outputs/fvp/)
endfunction()

#Adds the test directory
add_subdirectory(${TFM_ROOT_DIR}/test ${CMAKE_BINARY_DIR}/test/secure_test)

#Add the crypto library target
if (TFM_PARTITION_CRYPTO)
	add_subdirectory(${SECURE_FW_DIR}/services/crypto)
endif()

#Add the secure storage library target
if (TFM_PARTITION_SECURE_STORAGE)
	add_subdirectory(${SECURE_FW_DIR}/services/secure_storage)
endif()

#Add the internal trusted storage library target
if (TFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
	add_subdirectory(${SECURE_FW_DIR}/services/internal_trusted_storage)
endif()

#Add the platform service library target
if (TFM_PARTITION_PLATFORM)
	add_subdirectory(${SECURE_FW_DIR}/services/platform)
endif()

#Add the initial attestation service library target
if (TFM_PARTITION_INITIAL_ATTESTATION)
	add_subdirectory(${SECURE_FW_DIR}/services/initial_attestation)
endif()

#Add the audit logging library target
if (TFM_PARTITION_AUDIT_LOG)
	add_subdirectory(${SECURE_FW_DIR}/services/audit_logging)
endif()

#Add the secure runtime library target
add_subdirectory(${SECURE_FW_DIR}/lib/sprt)

if (NOT DEFINED TFM_MULTI_CORE_TOPOLOGY OR NOT TFM_MULTI_CORE_TOPOLOGY)
	#Broadcast veneer path in bundled building case
	set(S_VENEER_PATH "${CMAKE_CURRENT_BINARY_DIR}" CACHE INTERNAL "")
endif()

if (LINK_TO_BOTH_MEMORY_REGION)
	#Link to primary memory region
	set_up_secure_fw_build(S_TARGET      ${PROJECT_NAME}
						   VENEER_NAME   s_veneers)

	#Link to secondary memory region(add extra linker flag)
	set_up_secure_fw_build(S_TARGET      ${PROJECT_NAME}
						   LINK_DEFINES  "LINK_TO_SECONDARY_PARTITION"
						   VENEER_NAME   s_veneers
						   POSTFIX       "_1")
else()
	#Link to primary memory region only
	set_up_secure_fw_build(S_TARGET      ${PROJECT_NAME}
						   VENEER_NAME   s_veneers)
endif()

#Finally let CMake system apply changes after the whole project is defined.
if (TARGET ${PROJECT_NAME})
	embedded_project_end(${PROJECT_NAME})
endif()

if (TARGET ${PROJECT_NAME}_1)
	embedded_project_end(${PROJECT_NAME}_1)
endif()

embedded_project_end(${PROJECT_OBJ_LIB})