Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Raef Coles | dfe519b | 2021-01-07 12:52:47 +0000 | [diff] [blame] | 2 | # Copyright (c) 2020-2021, 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 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 8 | cmake_minimum_required(VERSION 3.15) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 9 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 10 | add_executable(tfm_s) |
| 11 | add_library(secure_fw INTERFACE) |
Summer Qin | 5a212ec | 2020-11-19 15:48:57 +0800 | [diff] [blame] | 12 | add_library(tfm_secure_api INTERFACE) |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 13 | add_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 |
| 19 | add_library(tfm_partition_defs INTERFACE) |
David Hu | 857bfa5 | 2019-05-21 13:54:50 +0800 | [diff] [blame] | 20 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 21 | add_subdirectory(partitions/lib/sprt) |
| 22 | add_subdirectory(partitions/audit_logging) |
| 23 | add_subdirectory(partitions/crypto) |
| 24 | add_subdirectory(partitions/initial_attestation) |
| 25 | add_subdirectory(partitions/protected_storage) |
| 26 | add_subdirectory(partitions/internal_trusted_storage) |
| 27 | add_subdirectory(partitions/platform) |
Mark Horvath | 652b900 | 2020-09-08 20:42:05 +0200 | [diff] [blame] | 28 | add_subdirectory(partitions/psa_proxy) |
Sherry Zhang | 07b4241 | 2021-01-07 14:19:41 +0800 | [diff] [blame] | 29 | add_subdirectory(partitions/firmware_update) |
Mingyang Sun | bc7c996 | 2021-01-26 10:33:52 +0800 | [diff] [blame] | 30 | add_subdirectory(partitions/tfm_ffm11_partition) |
Mingyang Sun | f6a7857 | 2021-04-02 16:51:05 +0800 | [diff] [blame] | 31 | add_subdirectory(partitions/ns_proxy_partition) |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 32 | add_subdirectory(spm) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 33 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 34 | target_include_directories(secure_fw |
| 35 | INTERFACE |
| 36 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 37 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/partitions> |
| 38 | ) |
Ken Liu | e40f9a2 | 2019-06-03 16:42:47 +0800 | [diff] [blame] | 39 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 40 | target_link_libraries(secure_fw |
| 41 | INTERFACE |
| 42 | tfm_spm |
| 43 | tfm_partitions |
| 44 | ) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 45 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 46 | target_link_libraries(tfm_s |
| 47 | PRIVATE |
| 48 | secure_fw |
| 49 | platform_s |
| 50 | psa_interface |
| 51 | tfm_sprt |
| 52 | ) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 53 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 54 | set_target_properties(tfm_s |
| 55 | PROPERTIES |
| 56 | SUFFIX ".axf" |
| 57 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" |
| 58 | ) |
Gyorgy Szing | d9c57fb | 2019-09-02 17:08:18 +0200 | [diff] [blame] | 59 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 60 | target_link_options(tfm_s |
| 61 | PRIVATE |
| 62 | --entry=Reset_Handler |
| 63 | $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_s.map> |
| 64 | $<$<C_COMPILER_ID:ARMClang>:--map> |
TTornblom | af19ae9 | 2020-09-29 13:26:29 +0200 | [diff] [blame] | 65 | $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_s.map> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 66 | ) |
| 67 | |
| 68 | add_convert_to_bin_target(tfm_s) |
| 69 | |
| 70 | ############################ Secure API ######################################## |
| 71 | |
| 72 | target_include_directories(tfm_secure_api |
Summer Qin | 5a212ec | 2020-11-19 15:48:57 +0800 | [diff] [blame] | 73 | INTERFACE |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 74 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 75 | ) |
| 76 | |
| 77 | target_link_libraries(tfm_secure_api |
Summer Qin | 5a212ec | 2020-11-19 15:48:57 +0800 | [diff] [blame] | 78 | INTERFACE |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 79 | tfm_arch |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 80 | ) |
| 81 | |
| 82 | set_source_files_properties( |
| 83 | ${CMAKE_SOURCE_DIR}/interface/src/psa/psa_client.c |
| 84 | ${CMAKE_SOURCE_DIR}/interface/src/psa/psa_service.c |
| 85 | PROPERTIES |
Raef Coles | 5e8ea84 | 2020-09-25 10:36:16 +0100 | [diff] [blame] | 86 | COMPILE_FLAGS $<$<C_COMPILER_ID:GNU>:-Wno-unused-parameter> |
| 87 | COMPILE_FLAGS $<$<C_COMPILER_ID:ARMClang>:-Wno-unused-parameter> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 88 | ) |
| 89 | |
| 90 | ############################# Secure veneers ################################### |
| 91 | |
| 92 | if(NOT (TFM_PSA_API AND TFM_MULTI_CORE_TOPOLOGY)) |
| 93 | add_library(tfm_s_veneers STATIC) |
| 94 | |
| 95 | target_sources(tfm_s_veneers |
| 96 | PRIVATE |
| 97 | ${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o |
| 98 | ) |
| 99 | |
| 100 | # Since s_veneers.o doesn't exist when this is evaluated by cmake we need to |
| 101 | # explicity specify what language it will use. |
| 102 | set_target_properties(tfm_s_veneers |
| 103 | PROPERTIES |
| 104 | LINKER_LANGUAGE C |
| 105 | ) |
| 106 | |
| 107 | # Pretend we have a command to generate the veneers, when in reality all |
| 108 | # that's needed is the dependency on tfm_s. This is required for the ninja |
| 109 | # build system |
| 110 | add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o |
| 111 | COMMAND |
| 112 | DEPENDS tfm_s |
| 113 | ) |
| 114 | |
| 115 | target_link_options(tfm_s |
| 116 | PRIVATE |
| 117 | ${LINKER_VENEER_OUTPUT_FLAG}${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o |
| 118 | ) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 119 | endif() |
Tamas Ban | f8b0b2d | 2020-10-26 13:03:13 +0000 | [diff] [blame] | 120 | |
| 121 | ############################### CODE SHARING ################################### |
| 122 | if (TFM_CODE_SHARING) |
| 123 | set(LIB_LIST mbedcrypto |
| 124 | crypto_service_cc312 |
| 125 | platform_s |
Raef Coles | dfe519b | 2021-01-07 12:52:47 +0000 | [diff] [blame] | 126 | tfm_psa_rot_partition_crypto |
| 127 | tfm_psa_rot_partition_audit |
| 128 | tfm_psa_rot_partition_attestation |
| 129 | tfm_app_rot_partition_ps |
| 130 | tfm_psa_rot_partition_its |
| 131 | tfm_psa_rot_partition_platform |
Tamas Ban | f8b0b2d | 2020-10-26 13:03:13 +0000 | [diff] [blame] | 132 | platform_s |
| 133 | tfm_sprt |
| 134 | tfm_spm |
| 135 | ) |
| 136 | if (TFM_CODE_SHARING_PATH) |
| 137 | compiler_link_shared_code(tfm_s |
| 138 | ${TFM_CODE_SHARING_PATH} # Path to shared code |
| 139 | EXTERNAL_TARGET # Not produced by tf-m build |
| 140 | "${LIB_LIST}" |
| 141 | ) |
| 142 | else() |
| 143 | compiler_link_shared_code(tfm_s |
| 144 | ${CMAKE_CURRENT_BINARY_DIR}/../bl2 |
| 145 | bl2 |
| 146 | "${LIB_LIST}" |
| 147 | ) |
| 148 | endif() |
| 149 | endif() |