1#-------------------------------------------------------------------------------
2# Copyright (c) 2023, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8# Load defaults, setting options not already set
9include(config/config_base.cmake)
10
11# Load regression configs overrided by platform
12include(${TARGET_PLATFORM_PATH}/reg_config_override.cmake OPTIONAL)
13
14# Fetch tf-m-tests repo during config, if NS or regression test is required.
15# Therefore tf-m-tests configs can be set with TF-M configs since their configs
16# are coupled.
17include(lib/ext/tf-m-tests/fetch_repo.cmake)
18
19# Load TF-M regression test suites setting
20if(NOT USE_KCONFIG_TOOL AND (TFM_NS_REG_TEST OR TFM_S_REG_TEST))
21    include(${TFM_TEST_PATH}/config/set_config.cmake)
22endif()
23
24# Build system log config
25include(${CMAKE_SOURCE_DIR}/config/tfm_build_log_config.cmake)
26
27# The library to collect compile definitions of config options.
28add_library(tfm_config INTERFACE)
29
30target_compile_definitions(tfm_config
31    INTERFACE
32        $<$<STREQUAL:${TEST_PSA_API},CRYPTO>:PSA_API_TEST_CRYPTO>
33        $<$<STREQUAL:${TEST_PSA_API},IPC>:PSA_API_TEST_IPC>
34)
35
36# Set user defined TF-M config header file
37if(PROJECT_CONFIG_HEADER_FILE)
38    if(NOT EXISTS ${PROJECT_CONFIG_HEADER_FILE})
39        message(FATAL_ERROR "${PROJECT_CONFIG_HEADER_FILE} does not exist! Please use absolute path.")
40    endif()
41    target_compile_definitions(tfm_config
42        INTERFACE
43            PROJECT_CONFIG_HEADER_FILE="${PROJECT_CONFIG_HEADER_FILE}"
44    )
45endif()
46
47# Set platform defined TF-M config header file
48set(TARGET_CONFIG_HEADER_FILE ${TARGET_PLATFORM_PATH}/config_tfm_target.h)
49if(EXISTS ${TARGET_CONFIG_HEADER_FILE})
50    target_compile_definitions(tfm_config
51        INTERFACE
52            TARGET_CONFIG_HEADER_FILE="${TARGET_CONFIG_HEADER_FILE}"
53    )
54endif()
55
56target_include_directories(tfm_config
57    INTERFACE
58        ${CMAKE_CURRENT_LIST_DIR}
59)
60