1#-------------------------------------------------------------------------------
2# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8cmake_minimum_required(VERSION 3.21)
9
10add_library(tfm_partitions INTERFACE)
11target_link_libraries(tfm_partitions
12    INTERFACE
13        tfm_spm_defs
14)
15
16add_subdirectory(lib/runtime)
17add_subdirectory(crypto)
18add_subdirectory(initial_attestation)
19add_subdirectory(protected_storage)
20add_subdirectory(internal_trusted_storage)
21add_subdirectory(platform)
22add_subdirectory(firmware_update)
23add_subdirectory(ns_agent_tz)
24add_subdirectory(ns_agent_mailbox)
25if (CONFIG_TFM_SPM_BACKEND_IPC)
26    add_subdirectory(idle_partition)
27endif()
28
29if (TFM_EXTRAS_REPO_EXTRA_PARTITIONS)
30    set(TMP_EXRAS_REPO_PARTITION ${TFM_EXTRAS_REPO_EXTRA_PARTITIONS})
31    list(TRANSFORM TMP_EXRAS_REPO_PARTITION PREPEND ${TFM_EXTRAS_REPO_PATH}/partitions/)
32    list(APPEND TEMP_TFM_EXTRA_PARTITION_PATHS ${TMP_EXRAS_REPO_PARTITION})
33endif()
34
35list(APPEND TEMP_TFM_EXTRA_PARTITION_PATHS ${TFM_EXTRA_PARTITION_PATHS})
36
37# Remove any duplicate entries to prevent same path appended twice in case of mulitiple runs
38list(REMOVE_DUPLICATES TEMP_TFM_EXTRA_PARTITION_PATHS)
39
40if (TEMP_TFM_EXTRA_PARTITION_PATHS)
41    set(POSTFIX 1)
42
43    foreach(EXTRA_PARTITION IN LISTS TEMP_TFM_EXTRA_PARTITION_PATHS)
44        get_filename_component(EXTRA_PARTITION_NAME ${EXTRA_PARTITION} NAME_WLE)
45        set(TEMP_BINARY_EXTRA_PARTITION
46            ${CMAKE_CURRENT_BINARY_DIR}/partitions/${EXTRA_PARTITION_NAME}_${POSTFIX})
47        add_subdirectory(${EXTRA_PARTITION} ${TEMP_BINARY_EXTRA_PARTITION})
48
49        math(EXPR POSTFIX "${POSTFIX} + 1")
50    endforeach()
51endif()
52
53target_compile_definitions(tfm_config
54    INTERFACE
55        $<$<STREQUAL:${TEST_PSA_API},IPC>:PSA_API_TEST_IPC>
56)
57