blob: 0b10f7e4493b583a301ff1704ef2f8fb60eb7d02 [file] [log] [blame]
Raef Coles958aeef2020-10-08 12:12:58 +01001#-------------------------------------------------------------------------------
Kevin Pengc32279d2022-02-10 11:11:55 +08002# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
Raef Coles958aeef2020-10-08 12:12:58 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8# The Configuration sequence is captured in the documentation, in
9# docs/getting_started/tfm_build_instructions.rst under Cmake Configuration. If
10# the sequence is updated here the docs must also be updated.
11
Dávid Házie50f0a92022-07-06 14:46:01 +020012# The default build type is MinSizeRel. If debug symbols are needed then
13# -DCMAKE_BUILD_TYPE=debug should be used (likewise with other build types)
14if (NOT CMAKE_BUILD_TYPE)
15 set(CMAKE_BUILD_TYPE "MinSizeRel" CACHE STRING "Build type: [Debug, Release, RelWithDebInfo, MinSizeRel]" FORCE)
16endif()
17
Summer Qin566e03b2022-10-08 17:27:42 +080018if (TFM_LIB_MODEL)
19 message(FATAL_ERROR "Library Model is deprecated, please DO NOT use TFM_LIB_MODEL anymore."
20 "SFN model is a replacement for Library Model. You can use -DCONFIG_TFM_SPM_BACKEND=SFN to select SFN model.")
21endif()
22
Tamas Ban69219202020-10-27 08:13:18 +000023# Load extra config
24if (TFM_EXTRA_CONFIG_PATH)
25 include(${TFM_EXTRA_CONFIG_PATH})
26endif()
Raef Coles958aeef2020-10-08 12:12:58 +010027
Tamas Ban69219202020-10-27 08:13:18 +000028# Load PSA config, setting options not already set
29if (TEST_PSA_API)
30 include(config/tests/config_test_psa_api.cmake)
31endif()
32
33# Load build type config, setting options not already set
Raef Coles958aeef2020-10-08 12:12:58 +010034string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWERCASE)
35if (EXISTS ${CMAKE_SOURCE_DIR}/config/build_type/${CMAKE_BUILD_TYPE_LOWERCASE}.cmake)
36 include(${CMAKE_SOURCE_DIR}/config/build_type/${CMAKE_BUILD_TYPE_LOWERCASE}.cmake)
37endif()
38
David Hu195cb5a2022-05-10 22:03:26 +080039# Parse tf-m-tests config prior to platform specific config.cmake
40# Some platforms select different configuration according when regression tests
41# are enabled.
42include(lib/ext/tf-m-tests/pre_parse.cmake)
43
Tamas Ban69219202020-10-27 08:13:18 +000044# Load platform config, setting options not already set
Kevin Peng38800662021-07-14 10:28:23 +080045if (EXISTS ${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/config.cmake)
Tamas Ban69219202020-10-27 08:13:18 +000046 include(platform/ext/target/${TFM_PLATFORM}/config.cmake)
Raef Coles958aeef2020-10-08 12:12:58 +010047endif()
48
Tamas Ban69219202020-10-27 08:13:18 +000049# Load accelerator config, setting options not already set
50if (CRYPTO_HW_ACCELERATOR)
51 if (EXISTS ${CMAKE_SOURCE_DIR}/platform/ext/accelerator/${CRYPTO_HW_ACCELERATOR_TYPE}/config.cmake)
52 include(${CMAKE_SOURCE_DIR}/platform/ext/accelerator/${CRYPTO_HW_ACCELERATOR_TYPE}/config.cmake)
53 endif()
54endif()
55
56# Load profile config, setting options not already set
Raef Coles958aeef2020-10-08 12:12:58 +010057if (TFM_PROFILE)
Tamas Ban69219202020-10-27 08:13:18 +000058 include(config/profile/${TFM_PROFILE}.cmake)
Raef Coles958aeef2020-10-08 12:12:58 +010059endif()
60
David Hudcc5a4a2022-11-14 17:59:11 +080061# Load Secure Partition settings according to regression configuration as all SPs are disabled
62# by default
63if(TFM_S_REG_TEST OR TFM_NS_REG_TEST)
64 include(${CMAKE_CURRENT_LIST_DIR}/tests/regression_config.cmake)
65endif()
66
Kevin Pengc32279d2022-02-10 11:11:55 +080067include(${CMAKE_SOURCE_DIR}/config/tfm_build_log_config.cmake)
68
David Hu372b45c2022-11-16 10:06:28 +080069# Load TF-M model specific default config
70# Load IPC backend config ifiIsolation level is explicitly specified to 2/3 or IPC backend is
71# selected via build command line. Otherwise, load SFN backend config by default.
72# If a pair of invalid settings are passed via command line, it will be captured later via config
73# check.
74# Also select IPC model by default for multi-core platform unless it has already selected SFN model
75if ((DEFINED TFM_ISOLATION_LEVEL AND TFM_ISOLATION_LEVEL GREATER 1) OR
76 CONFIG_TFM_SPM_BACKEND STREQUAL "IPC" OR
77 TFM_MULTI_CORE_TOPOLOGY)
78 include(config/tfm_ipc_config_default.cmake)
79else()
80 #The default backend is SFN
81 include(config/tfm_sfn_config_default.cmake)
82endif()
83
Raef Coles15a37f82021-12-07 15:59:14 +000084# Load bl1 config
Raef Colesd32f6bf2022-04-19 15:13:00 +010085if (BL1 AND PLATFORM_DEFAULT_BL1)
Raef Coles15a37f82021-12-07 15:59:14 +000086 include(${CMAKE_SOURCE_DIR}/bl1/config/bl1_config_default.cmake)
87endif()
88
shejia0184440112021-07-07 10:49:09 +080089# Load MCUboot specific default.cmake
Raef Colesf0ba05b2021-11-25 09:57:17 +000090if (NOT DEFINED BL2 OR BL2)
shejia0184440112021-07-07 10:49:09 +080091 include(${CMAKE_SOURCE_DIR}/bl2/ext/mcuboot/mcuboot_default_config.cmake)
92endif()
93
Sherry Zhang71468952022-10-19 14:09:05 +080094# Include FWU partition configs.
95include(config/tfm_fwu_config.cmake)
96
Feder Liangd4dbaa92021-09-07 15:34:46 +080097# Include coprocessor configs
98include(config/cp_config_default.cmake)
99
Ludovic Barre5319ac02021-11-02 09:51:29 +0100100# Load defaults, setting options not already set
Anton Komlev1dfd2092022-10-25 17:50:09 +0100101include(config/config_base.cmake)
Ludovic Barre5319ac02021-11-02 09:51:29 +0100102
David Hu3d2121f2021-08-23 18:00:26 +0800103# Fetch tf-m-tests repo during config, if NS or regression test is required.
104# Therefore tf-m-tests configs can be set with TF-M configs since their configs
105# are coupled.
David Hu195cb5a2022-05-10 22:03:26 +0800106include(lib/ext/tf-m-tests/fetch_repo.cmake)
David Hu52ff16f2021-08-20 11:39:37 +0800107
108# Set secure log configs
109# It also depends on regression test config.
110include(config/tfm_secure_log.cmake)
Xinyu Zhanga2fab0e2022-10-24 15:37:46 +0800111
112add_library(tfm_config INTERFACE)
113
114# Set user defined TF-M config header file
115if(PROJECT_CONFIG_HEADER_FILE)
116 if(NOT EXISTS ${PROJECT_CONFIG_HEADER_FILE})
117 message(FATAL_ERROR "${PROJECT_CONFIG_HEADER_FILE} does not exist! Please use absolute path.")
118 endif()
119 target_compile_definitions(tfm_config
120 INTERFACE
121 PROJECT_CONFIG_HEADER_FILE="${PROJECT_CONFIG_HEADER_FILE}"
122 )
123endif()
124
125# Set platform defined TF-M config header file
126set(TARGET_CONFIG_HEADER_FILE "${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/config_tfm_target.h")
127if(EXISTS ${TARGET_CONFIG_HEADER_FILE})
128 target_compile_definitions(tfm_config
129 INTERFACE
130 TARGET_CONFIG_HEADER_FILE="${TARGET_CONFIG_HEADER_FILE}"
131 )
132endif()