blob: afe1d0f400ed5fa1adec3423f24cb6e9bb96dc1f [file] [log] [blame]
Gyorgy Szing30fa9872017-12-05 01:08:47 +00001#-------------------------------------------------------------------------------
Raef Colesdfe519b2021-01-07 12:52:47 +00002# Copyright (c) 2020-2021, Arm Limited. All rights reserved.
Gyorgy Szing30fa9872017-12-05 01:08:47 +00003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
Raef Coles69817322020-10-19 14:14:14 +01008cmake_minimum_required(VERSION 3.15)
Gyorgy Szing30fa9872017-12-05 01:08:47 +00009
Raef Colesabfe81a2020-07-10 09:52:34 +010010add_executable(tfm_s)
11add_library(secure_fw INTERFACE)
Summer Qin5a212ec2020-11-19 15:48:57 +080012add_library(tfm_secure_api INTERFACE)
Raef Colesabfe81a2020-07-10 09:52:34 +010013add_library(tfm_partitions INTERFACE)
14# Lots of seperate things need to know which partitions are enabled, so this
15# meta-target is provided so the related compile definitions can be collected in
16# such a way that they don't cause issues with linking to the full spm (which is
17# the other place these could be collected) Actual definitions are placed in the
18# directories of the partitions
19add_library(tfm_partition_defs INTERFACE)
David Hu857bfa52019-05-21 13:54:50 +080020
Raef Colesabfe81a2020-07-10 09:52:34 +010021add_subdirectory(partitions/lib/sprt)
22add_subdirectory(partitions/audit_logging)
23add_subdirectory(partitions/crypto)
24add_subdirectory(partitions/initial_attestation)
25add_subdirectory(partitions/protected_storage)
26add_subdirectory(partitions/internal_trusted_storage)
27add_subdirectory(partitions/platform)
Mark Horvath652b9002020-09-08 20:42:05 +020028add_subdirectory(partitions/psa_proxy)
Sherry Zhang07b42412021-01-07 14:19:41 +080029add_subdirectory(partitions/firmware_update)
Mingyang Sunbc7c9962021-01-26 10:33:52 +080030add_subdirectory(partitions/tfm_ffm11_partition)
Raef Colesabfe81a2020-07-10 09:52:34 +010031add_subdirectory(spm)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000032
Raef Colesabfe81a2020-07-10 09:52:34 +010033target_include_directories(secure_fw
34 INTERFACE
35 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
36 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/partitions>
37)
Ken Liue40f9a22019-06-03 16:42:47 +080038
Raef Colesabfe81a2020-07-10 09:52:34 +010039target_link_libraries(secure_fw
40 INTERFACE
41 tfm_spm
42 tfm_partitions
43)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000044
Raef Colesabfe81a2020-07-10 09:52:34 +010045target_link_libraries(tfm_s
46 PRIVATE
47 secure_fw
48 platform_s
49 psa_interface
50 tfm_sprt
51)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000052
Raef Colesabfe81a2020-07-10 09:52:34 +010053set_target_properties(tfm_s
54 PROPERTIES
55 SUFFIX ".axf"
56 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
57)
Gyorgy Szingd9c57fb2019-09-02 17:08:18 +020058
Raef Colesabfe81a2020-07-10 09:52:34 +010059target_link_options(tfm_s
60 PRIVATE
61 --entry=Reset_Handler
62 $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_s.map>
63 $<$<C_COMPILER_ID:ARMClang>:--map>
TTornblomaf19ae92020-09-29 13:26:29 +020064 $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_s.map>
Raef Colesabfe81a2020-07-10 09:52:34 +010065)
66
67add_convert_to_bin_target(tfm_s)
68
69############################ Secure API ########################################
70
71target_include_directories(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +080072 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +010073 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
74)
75
76target_link_libraries(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +080077 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +010078 tfm_arch
Raef Colesabfe81a2020-07-10 09:52:34 +010079)
80
81set_source_files_properties(
82 ${CMAKE_SOURCE_DIR}/interface/src/psa/psa_client.c
83 ${CMAKE_SOURCE_DIR}/interface/src/psa/psa_service.c
84 PROPERTIES
Raef Coles5e8ea842020-09-25 10:36:16 +010085 COMPILE_FLAGS $<$<C_COMPILER_ID:GNU>:-Wno-unused-parameter>
86 COMPILE_FLAGS $<$<C_COMPILER_ID:ARMClang>:-Wno-unused-parameter>
Raef Colesabfe81a2020-07-10 09:52:34 +010087)
88
89############################# Secure veneers ###################################
90
91if(NOT (TFM_PSA_API AND TFM_MULTI_CORE_TOPOLOGY))
92 add_library(tfm_s_veneers STATIC)
93
94 target_sources(tfm_s_veneers
95 PRIVATE
96 ${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o
97 )
98
99 # Since s_veneers.o doesn't exist when this is evaluated by cmake we need to
100 # explicity specify what language it will use.
101 set_target_properties(tfm_s_veneers
102 PROPERTIES
103 LINKER_LANGUAGE C
104 )
105
106 # Pretend we have a command to generate the veneers, when in reality all
107 # that's needed is the dependency on tfm_s. This is required for the ninja
108 # build system
109 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o
110 COMMAND
111 DEPENDS tfm_s
112 )
113
114 target_link_options(tfm_s
115 PRIVATE
116 ${LINKER_VENEER_OUTPUT_FLAG}${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o
117 )
Gyorgy Szing30fa9872017-12-05 01:08:47 +0000118endif()
Tamas Banf8b0b2d2020-10-26 13:03:13 +0000119
120############################### CODE SHARING ###################################
121if (TFM_CODE_SHARING)
122 set(LIB_LIST mbedcrypto
123 crypto_service_cc312
124 platform_s
Raef Colesdfe519b2021-01-07 12:52:47 +0000125 tfm_psa_rot_partition_crypto
126 tfm_psa_rot_partition_audit
127 tfm_psa_rot_partition_attestation
128 tfm_app_rot_partition_ps
129 tfm_psa_rot_partition_its
130 tfm_psa_rot_partition_platform
Tamas Banf8b0b2d2020-10-26 13:03:13 +0000131 platform_s
132 tfm_sprt
133 tfm_spm
134 )
135 if (TFM_CODE_SHARING_PATH)
136 compiler_link_shared_code(tfm_s
137 ${TFM_CODE_SHARING_PATH} # Path to shared code
138 EXTERNAL_TARGET # Not produced by tf-m build
139 "${LIB_LIST}"
140 )
141 else()
142 compiler_link_shared_code(tfm_s
143 ${CMAKE_CURRENT_BINARY_DIR}/../bl2
144 bl2
145 "${LIB_LIST}"
146 )
147 endif()
148endif()