1#-------------------------------------------------------------------------------
2# Copyright (c) 2020-2023, Arm Limited. All rights reserved.
3# Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
4# or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
5#
6# SPDX-License-Identifier: BSD-3-Clause
7#
8#-------------------------------------------------------------------------------
9
10cmake_minimum_required(VERSION 3.15)
11
12# CMake 3.21 and above requests projects to specify cpu/arch compile and link flags explicitly in
13# Armclang. Link: https://cmake.org/cmake/help/latest/policy/CMP0123.html
14# It is aligned with current Armclang toolchain implementation.
15# Explictly set this policy to NEW behavior to eliminate long warnings. It shall be set in root
16# CMakeLists.txt otherwise project() will throw out the warnings.
17if(POLICY CMP0123)
18    cmake_policy(SET CMP0123 NEW)
19endif()
20
21list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
22include(version)
23include(remote_library)
24include(utils)
25
26if(EXISTS ${CMAKE_SOURCE_DIR}/localrepos.cmake)
27    message(WARNING "Building using local repositories from \"" ${CMAKE_SOURCE_DIR}/localrepos.cmake "\"")
28    include(${CMAKE_SOURCE_DIR}/localrepos.cmake)
29endif()
30
31############################ CONFIGURATION #####################################
32include(config/pre_config.cmake)
33
34if(USE_KCONFIG_TOOL)
35    include(${CMAKE_SOURCE_DIR}/config/kconfig.cmake)
36else()
37    include(${CMAKE_SOURCE_DIR}/config/set_config.cmake)
38endif()
39
40include(config/post_config.cmake)
41
42############################### Compiler configuration #########################
43
44include(${TFM_TOOLCHAIN_FILE})
45
46set(CMAKE_C_COMPILER_FORCED true)
47set(CMAKE_CXX_COMPILER_FORCED true)
48
49project("Trusted Firmware M" VERSION ${TFM_VERSION} LANGUAGES C CXX ASM)
50tfm_toolchain_reload_compiler()
51
52add_subdirectory(lib/ext)
53add_subdirectory(lib/fih)
54add_subdirectory(tools)
55add_subdirectory(secure_fw)
56
57add_subdirectory(interface)
58if(BL2)
59    add_subdirectory(bl2)
60endif()
61
62if(BL1 AND PLATFORM_DEFAULT_BL1)
63    add_subdirectory(bl1/bl1_2)
64    add_subdirectory(bl1/bl1_1)
65endif()
66
67add_subdirectory(platform)
68
69if(CRYPTO_HW_ACCELERATOR)
70    add_subdirectory(platform/ext/accelerator)
71endif()
72
73if(IS_DIRECTORY ${CONFIG_TFM_TEST_DIR})
74    add_subdirectory(${CONFIG_TFM_TEST_DIR} ${CMAKE_CURRENT_BINARY_DIR}/tf-m-tests)
75endif()
76
77############################ Config Check ######################################
78
79include(${CMAKE_SOURCE_DIR}/config/check_config.cmake)
80
81################################################################################
82
83include(cmake/install.cmake)
84