blob: bf8d21aa88317f1efe7068b5f5e330e32af08a00 [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
Kevin Peng33d03942021-06-08 11:28:41 +080021add_subdirectory(spm)
Raef Colesabfe81a2020-07-10 09:52:34 +010022add_subdirectory(partitions/lib/sprt)
23add_subdirectory(partitions/audit_logging)
24add_subdirectory(partitions/crypto)
25add_subdirectory(partitions/initial_attestation)
26add_subdirectory(partitions/protected_storage)
27add_subdirectory(partitions/internal_trusted_storage)
28add_subdirectory(partitions/platform)
Mark Horvath652b9002020-09-08 20:42:05 +020029add_subdirectory(partitions/psa_proxy)
Sherry Zhang07b42412021-01-07 14:19:41 +080030add_subdirectory(partitions/firmware_update)
Mingyang Sunbc7c9962021-01-26 10:33:52 +080031add_subdirectory(partitions/tfm_ffm11_partition)
Mingyang Sunf6a78572021-04-02 16:51:05 +080032add_subdirectory(partitions/ns_proxy_partition)
Kevin Peng33d03942021-06-08 11:28:41 +080033add_subdirectory(partitions/idle_partition)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000034
Raef Colesabfe81a2020-07-10 09:52:34 +010035target_include_directories(secure_fw
36 INTERFACE
37 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
38 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/partitions>
39)
Ken Liue40f9a22019-06-03 16:42:47 +080040
Raef Colesabfe81a2020-07-10 09:52:34 +010041target_link_libraries(secure_fw
42 INTERFACE
43 tfm_spm
44 tfm_partitions
45)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000046
Raef Colesabfe81a2020-07-10 09:52:34 +010047target_link_libraries(tfm_s
48 PRIVATE
49 secure_fw
50 platform_s
51 psa_interface
52 tfm_sprt
53)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000054
Raef Colesabfe81a2020-07-10 09:52:34 +010055set_target_properties(tfm_s
56 PROPERTIES
57 SUFFIX ".axf"
58 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
59)
Gyorgy Szingd9c57fb2019-09-02 17:08:18 +020060
Raef Colesabfe81a2020-07-10 09:52:34 +010061target_link_options(tfm_s
62 PRIVATE
63 --entry=Reset_Handler
64 $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_s.map>
65 $<$<C_COMPILER_ID:ARMClang>:--map>
TTornblomaf19ae92020-09-29 13:26:29 +020066 $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_s.map>
Raef Colesabfe81a2020-07-10 09:52:34 +010067)
68
69add_convert_to_bin_target(tfm_s)
70
71############################ Secure API ########################################
72
73target_include_directories(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +080074 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +010075 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
76)
77
78target_link_libraries(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +080079 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +010080 tfm_arch
Raef Colesabfe81a2020-07-10 09:52:34 +010081)
82
83set_source_files_properties(
84 ${CMAKE_SOURCE_DIR}/interface/src/psa/psa_client.c
85 ${CMAKE_SOURCE_DIR}/interface/src/psa/psa_service.c
86 PROPERTIES
Raef Coles5e8ea842020-09-25 10:36:16 +010087 COMPILE_FLAGS $<$<C_COMPILER_ID:GNU>:-Wno-unused-parameter>
88 COMPILE_FLAGS $<$<C_COMPILER_ID:ARMClang>:-Wno-unused-parameter>
Raef Colesabfe81a2020-07-10 09:52:34 +010089)
90
91############################# Secure veneers ###################################
92
93if(NOT (TFM_PSA_API AND TFM_MULTI_CORE_TOPOLOGY))
94 add_library(tfm_s_veneers STATIC)
95
96 target_sources(tfm_s_veneers
97 PRIVATE
98 ${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o
99 )
100
101 # Since s_veneers.o doesn't exist when this is evaluated by cmake we need to
102 # explicity specify what language it will use.
103 set_target_properties(tfm_s_veneers
104 PROPERTIES
105 LINKER_LANGUAGE C
106 )
107
108 # Pretend we have a command to generate the veneers, when in reality all
109 # that's needed is the dependency on tfm_s. This is required for the ninja
110 # build system
111 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o
112 COMMAND
113 DEPENDS tfm_s
114 )
115
116 target_link_options(tfm_s
117 PRIVATE
118 ${LINKER_VENEER_OUTPUT_FLAG}${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o
119 )
Gyorgy Szing30fa9872017-12-05 01:08:47 +0000120endif()
Tamas Banf8b0b2d2020-10-26 13:03:13 +0000121
122############################### CODE SHARING ###################################
123if (TFM_CODE_SHARING)
124 set(LIB_LIST mbedcrypto
125 crypto_service_cc312
126 platform_s
Raef Colesdfe519b2021-01-07 12:52:47 +0000127 tfm_psa_rot_partition_crypto
128 tfm_psa_rot_partition_audit
129 tfm_psa_rot_partition_attestation
130 tfm_app_rot_partition_ps
131 tfm_psa_rot_partition_its
132 tfm_psa_rot_partition_platform
Tamas Banf8b0b2d2020-10-26 13:03:13 +0000133 platform_s
134 tfm_sprt
135 tfm_spm
136 )
137 if (TFM_CODE_SHARING_PATH)
138 compiler_link_shared_code(tfm_s
139 ${TFM_CODE_SHARING_PATH} # Path to shared code
140 EXTERNAL_TARGET # Not produced by tf-m build
141 "${LIB_LIST}"
142 )
143 else()
144 compiler_link_shared_code(tfm_s
145 ${CMAKE_CURRENT_BINARY_DIR}/../bl2
146 bl2
147 "${LIB_LIST}"
148 )
149 endif()
150endif()