blob: a29a866017283069866ee874840760809908f9ac [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
Xinyu Zhange7581b12022-11-23 14:19:02 +080028# Set TF-M project config header file
29add_library(tfm_config INTERFACE)
30
Tamas Ban69219202020-10-27 08:13:18 +000031# Load PSA config, setting options not already set
32if (TEST_PSA_API)
33 include(config/tests/config_test_psa_api.cmake)
34endif()
35
36# Load build type config, setting options not already set
Raef Coles958aeef2020-10-08 12:12:58 +010037string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWERCASE)
38if (EXISTS ${CMAKE_SOURCE_DIR}/config/build_type/${CMAKE_BUILD_TYPE_LOWERCASE}.cmake)
39 include(${CMAKE_SOURCE_DIR}/config/build_type/${CMAKE_BUILD_TYPE_LOWERCASE}.cmake)
40endif()
41
Tamas Ban69219202020-10-27 08:13:18 +000042# Load platform config, setting options not already set
Kevin Peng38800662021-07-14 10:28:23 +080043if (EXISTS ${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/config.cmake)
Tamas Ban69219202020-10-27 08:13:18 +000044 include(platform/ext/target/${TFM_PLATFORM}/config.cmake)
Raef Coles958aeef2020-10-08 12:12:58 +010045endif()
46
Jianliang Shen7e48bef2022-10-31 16:15:36 +080047# Load configs generated from Kconfig
48include(${CMAKE_SOURCE_DIR}/config/kconfig.cmake)
49
50# Parse tf-m-tests config prior to platform specific config.cmake
51# Some platforms select different configuration according when regression tests
52# are enabled.
53include(lib/ext/tf-m-tests/reg_parse.cmake)
54
Tamas Ban69219202020-10-27 08:13:18 +000055# Load profile config, setting options not already set
Raef Coles958aeef2020-10-08 12:12:58 +010056if (TFM_PROFILE)
Tamas Ban69219202020-10-27 08:13:18 +000057 include(config/profile/${TFM_PROFILE}.cmake)
Raef Coles958aeef2020-10-08 12:12:58 +010058endif()
59
David Hudcc5a4a2022-11-14 17:59:11 +080060# Load Secure Partition settings according to regression configuration as all SPs are disabled
61# by default
62if(TFM_S_REG_TEST OR TFM_NS_REG_TEST)
63 include(${CMAKE_CURRENT_LIST_DIR}/tests/regression_config.cmake)
64endif()
65
Kevin Pengc32279d2022-02-10 11:11:55 +080066include(${CMAKE_SOURCE_DIR}/config/tfm_build_log_config.cmake)
67
David Hu372b45c2022-11-16 10:06:28 +080068# Load TF-M model specific default config
David Hu85a92e02022-11-23 10:44:58 +080069# Load IPC backend config if isolation level is explicitly specified to 2/3 or IPC backend is
David Hu372b45c2022-11-16 10:06:28 +080070# selected via build command line. Otherwise, load SFN backend config by default.
71# If a pair of invalid settings are passed via command line, it will be captured later via config
72# check.
73# Also select IPC model by default for multi-core platform unless it has already selected SFN model
74if ((DEFINED TFM_ISOLATION_LEVEL AND TFM_ISOLATION_LEVEL GREATER 1) OR
75 CONFIG_TFM_SPM_BACKEND STREQUAL "IPC" OR
76 TFM_MULTI_CORE_TOPOLOGY)
77 include(config/tfm_ipc_config_default.cmake)
78else()
79 #The default backend is SFN
80 include(config/tfm_sfn_config_default.cmake)
81endif()
82
Raef Coles15a37f82021-12-07 15:59:14 +000083# Load bl1 config
Raef Colesd32f6bf2022-04-19 15:13:00 +010084if (BL1 AND PLATFORM_DEFAULT_BL1)
Raef Coles15a37f82021-12-07 15:59:14 +000085 include(${CMAKE_SOURCE_DIR}/bl1/config/bl1_config_default.cmake)
86endif()
87
shejia0184440112021-07-07 10:49:09 +080088# Load MCUboot specific default.cmake
Raef Colesf0ba05b2021-11-25 09:57:17 +000089if (NOT DEFINED BL2 OR BL2)
shejia0184440112021-07-07 10:49:09 +080090 include(${CMAKE_SOURCE_DIR}/bl2/ext/mcuboot/mcuboot_default_config.cmake)
91endif()
92
Sherry Zhang71468952022-10-19 14:09:05 +080093# Include FWU partition configs.
94include(config/tfm_fwu_config.cmake)
95
Feder Liangd4dbaa92021-09-07 15:34:46 +080096# Include coprocessor configs
97include(config/cp_config_default.cmake)
98
Ludovic Barre5319ac02021-11-02 09:51:29 +010099# Load defaults, setting options not already set
Anton Komlev1dfd2092022-10-25 17:50:09 +0100100include(config/config_base.cmake)
Ludovic Barre5319ac02021-11-02 09:51:29 +0100101
David Hu3d2121f2021-08-23 18:00:26 +0800102# Fetch tf-m-tests repo during config, if NS or regression test is required.
103# Therefore tf-m-tests configs can be set with TF-M configs since their configs
104# are coupled.
David Hu195cb5a2022-05-10 22:03:26 +0800105include(lib/ext/tf-m-tests/fetch_repo.cmake)
David Hu52ff16f2021-08-20 11:39:37 +0800106
107# Set secure log configs
108# It also depends on regression test config.
109include(config/tfm_secure_log.cmake)
Xinyu Zhanga2fab0e2022-10-24 15:37:46 +0800110
Xinyu Zhanga2fab0e2022-10-24 15:37:46 +0800111# Set user defined TF-M config header file
112if(PROJECT_CONFIG_HEADER_FILE)
113 if(NOT EXISTS ${PROJECT_CONFIG_HEADER_FILE})
114 message(FATAL_ERROR "${PROJECT_CONFIG_HEADER_FILE} does not exist! Please use absolute path.")
115 endif()
116 target_compile_definitions(tfm_config
117 INTERFACE
118 PROJECT_CONFIG_HEADER_FILE="${PROJECT_CONFIG_HEADER_FILE}"
119 )
120endif()
121
122# Set platform defined TF-M config header file
123set(TARGET_CONFIG_HEADER_FILE "${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/config_tfm_target.h")
124if(EXISTS ${TARGET_CONFIG_HEADER_FILE})
125 target_compile_definitions(tfm_config
126 INTERFACE
127 TARGET_CONFIG_HEADER_FILE="${TARGET_CONFIG_HEADER_FILE}"
128 )
129endif()