blob: 9c19fafdb0b68cf444bf978b8803c0d0e557a1bd [file] [log] [blame]
Gyorgy Szing30fa9872017-12-05 01:08:47 +00001#-------------------------------------------------------------------------------
Raef Colesabfe81a2020-07-10 09:52:34 +01002# Copyright (c) 2020, Arm Limited. All rights reserved.
Gyorgy Szing30fa9872017-12-05 01:08:47 +00003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
Raef Colesabfe81a2020-07-10 09:52:34 +01008cmake_minimum_required(VERSION 3.13)
Gyorgy Szing30fa9872017-12-05 01:08:47 +00009
Raef Colesabfe81a2020-07-10 09:52:34 +010010add_executable(tfm_s)
11add_library(secure_fw INTERFACE)
12add_library(tfm_secure_api STATIC)
13add_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)
28add_subdirectory(spm)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000029
Raef Colesabfe81a2020-07-10 09:52:34 +010030target_include_directories(secure_fw
31 INTERFACE
32 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
33 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/partitions>
34)
Ken Liue40f9a22019-06-03 16:42:47 +080035
Raef Colesabfe81a2020-07-10 09:52:34 +010036target_link_libraries(secure_fw
37 INTERFACE
38 tfm_spm
39 tfm_partitions
40)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000041
Raef Colesabfe81a2020-07-10 09:52:34 +010042target_link_libraries(tfm_s
43 PRIVATE
44 secure_fw
45 platform_s
46 psa_interface
47 tfm_sprt
48)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000049
Raef Colesabfe81a2020-07-10 09:52:34 +010050set_target_properties(tfm_s
51 PROPERTIES
52 SUFFIX ".axf"
53 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
54)
Gyorgy Szingd9c57fb2019-09-02 17:08:18 +020055
Raef Colesabfe81a2020-07-10 09:52:34 +010056target_link_options(tfm_s
57 PRIVATE
58 --entry=Reset_Handler
59 $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_s.map>
60 $<$<C_COMPILER_ID:ARMClang>:--map>
TTornblomaf19ae92020-09-29 13:26:29 +020061 $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_s.map>
Raef Colesabfe81a2020-07-10 09:52:34 +010062)
63
64add_convert_to_bin_target(tfm_s)
65
66############################ Secure API ########################################
67
68target_include_directories(tfm_secure_api
69 PUBLIC
70 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
71)
72
73target_link_libraries(tfm_secure_api
74 PUBLIC
75 tfm_arch
76 PRIVATE
77 psa_interface
78 platform_s
79)
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()