blob: 44b674d9ad2c69a4434a9c1c28918f35d03ab728 [file] [log] [blame]
#-------------------------------------------------------------------------------
# Copyright (c) 2022-2023, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
#-------------------------------------------------------------------------------
# Load multiple config files and merge into one, generates CMake config file and config header file.
# The first loaded configs would be overridden by later ones. That's how the "merge" works.
# Check CONFIG_FILE_LIST for the loading order.
# Configurations not set by any of the config files would be set to the default values in Kconfig
# files with dependencies respected.
# If a ".config" already exists in the output folder, then the CONFIG_FILE_LIST is ignored.
# For more details, check the kconfig_system.rst.
set(KCONFIG_OUTPUT_DIR ${CMAKE_BINARY_DIR}/kconfig)
set(DOTCONFIG_FILE ${KCONFIG_OUTPUT_DIR}/.config)
set(ROOT_KCONFIG ${CMAKE_SOURCE_DIR}/Kconfig)
set(PLATFORM_KCONFIG ${TARGET_PLATFORM_PATH}/Kconfig)
if(TFM_PROFILE)
# Selecting TF-M profiles is not supported yet.
message(FATAL_ERROR "Selecting TF-M profiles is not supported yet in Kconfig system!")
endif()
if(NOT EXISTS ${PLATFORM_KCONFIG})
message(WARNING "The platform does not have Kconfig file! \
The Kconfig system cannot get its configuration settings.
So it is not guaranteed that the Kconfig system works properly.")
if(EXISTS ${TARGET_PLATFORM_PATH}/config.cmake)
include(${TARGET_PLATFORM_PATH}/config.cmake)
endif()
endif()
# User customized config file
if(DEFINED KCONFIG_CONFIG_FILE AND NOT EXISTS ${KCONFIG_CONFIG_FILE})
message(FATAL_ERROR "No such file: ${KCONFIG_CONFIG_FILE}")
endif()
# Note the order of CONFIG_FILE_LIST, as the first loaded configs would be
# overridden by later ones.
list(APPEND CONFIG_FILE_LIST
${KCONFIG_CONFIG_FILE})
# Set up ENV variables for the tfm_kconfig.py which are then consumed by Kconfig files.
set(KCONFIG_ENV_VARS "TFM_BASE=${CMAKE_SOURCE_DIR} \
TFM_VERSION=${TFM_VERSION} \
PLATFORM_PATH=${TARGET_PLATFORM_PATH} \
CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
if(MENUCONFIG)
# Note: Currently, only GUI menuconfig can be supported with CMake integration
set(MENUCONFIG_ARG "-u=gui")
else()
set(MENUCONFIG_ARG "")
endif()
find_package(Python3)
execute_process(
COMMAND
${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/kconfig/tfm_kconfig.py
-k ${ROOT_KCONFIG} -o ${KCONFIG_OUTPUT_DIR}
--envs ${KCONFIG_ENV_VARS}
--config-files ${CONFIG_FILE_LIST}
${MENUCONFIG_ARG}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE ret
)
if(NOT ret EQUAL 0)
message(FATAL_ERROR "Kconfig tool failed!")
endif()
if(DEFINED PROJECT_CONFIG_HEADER_FILE)
message(FATAL_ERROR "It is NOT supported to manually set PROJECT_CONFIG_HEADER_FILE while using Kconfig.")
endif()
# Component configs generated by tfm_kconfig.py
set(PROJECT_CONFIG_HEADER_FILE ${KCONFIG_OUTPUT_DIR}/project_config.h CACHE FILEPATH "User defined header file for TF-M config")
# Load project cmake configs generated by tfm_kconfig.py
include(${KCONFIG_OUTPUT_DIR}/project_config.cmake)
####################################################################################################
# The Kconfig system does not cover all the config options for the time being.
# So part of them still use the CMake config system.
# Load regression configs overrided by platform
if(EXISTS ${TARGET_PLATFORM_PATH}/reg_config_override.cmake)
include(${TARGET_PLATFORM_PATH}/reg_config_override.cmake)
endif()
# Load build type config, setting options not already set
if(EXISTS ${CMAKE_SOURCE_DIR}/config/build_type/${CMAKE_BUILD_TYPE_LOWERCASE}.cmake)
include(${CMAKE_SOURCE_DIR}/config/build_type/${CMAKE_BUILD_TYPE_LOWERCASE}.cmake)
endif()
# Load TF-M model specific default config
# Load IPC backend config if isolation level is explicitly specified to 2/3 or IPC backend is
# selected via build command line. Otherwise, load SFN backend config by default.
# If a pair of invalid settings are passed via command line, it will be captured later via config
# check.
# Also select IPC model by default for multi-core platform unless it has already selected SFN model
if((DEFINED TFM_ISOLATION_LEVEL AND TFM_ISOLATION_LEVEL GREATER 1) OR
CONFIG_TFM_SPM_BACKEND STREQUAL "IPC" OR
TFM_MULTI_CORE_TOPOLOGY)
include(config/tfm_ipc_config_default.cmake)
else()
#The default backend is SFN
include(config/tfm_sfn_config_default.cmake)
endif()
# Load bl1 config
if(BL1 AND PLATFORM_DEFAULT_BL1)
include(${CMAKE_SOURCE_DIR}/bl1/config/bl1_config_default.cmake)
endif()
# Load MCUboot specific default.cmake
if(NOT DEFINED BL2 OR BL2)
include(${CMAKE_SOURCE_DIR}/bl2/ext/mcuboot/mcuboot_default_config.cmake)
endif()
# Include FWU partition configs.
include(config/tfm_fwu_config.cmake)
# Include coprocessor configs
include(config/cp_config_default.cmake)
# Load defaults, setting options not already set
include(config/config_base.cmake)
# Set secure log configs
# It also depends on regression test config.
include(config/tfm_secure_log.cmake)