1#-------------------------------------------------------------------------------
2# Copyright (c) 2020-2022, 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(cmake/version.cmake)
23include(remote_library)
24
25############################ CONFIGURATION #####################################
26
27# Configure TFM_PLATFORM
28include(${CMAKE_SOURCE_DIR}/config/tfm_platform.cmake)
29
30if(TFM_SYSTEM_DSP)
31    message(FATAL_ERROR "Hardware DSP is currently not supported in TF-M")
32endif()
33
34include(config/set_config.cmake)
35
36if(NOT ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" AND
37   NOT ${CMAKE_GENERATOR} STREQUAL "Ninja")
38    Message(FATAL_ERROR "Unsupported generator ${CMAKE_GENERATOR}. Hint: Try -G\"Unix Makefiles\"")
39endif()
40
41############################### Compiler configuration #########################
42
43include(${TFM_TOOLCHAIN_FILE})
44set(CMAKE_PROJECT_INCLUDE_BEFORE ${CMAKE_SOURCE_DIR}/cmake/disable_compiler_detection.cmake)
45
46project("Trusted Firmware M" VERSION ${TFM_VERSION} LANGUAGES C ASM)
47tfm_toolchain_reload_compiler()
48
49# Synchronise the install path variables. If CMAKE_INSTALL_PREFIX is manually
50# set then set both to the value of that, else set both to the value of
51# TFM_INSTALL_PATH. This has to be done after the call to `project()`.
52if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
53    set(CMAKE_INSTALL_PREFIX  ${TFM_INSTALL_PATH} CACHE PATH  "" FORCE)
54else()
55    set(TFM_INSTALL_PATH  ${CMAKE_INSTALL_PREFIX} CACHE PATH  "Path to which to install TF-M files" FORCE)
56endif()
57
58add_subdirectory(lib/ext)
59add_subdirectory(lib/fih)
60add_subdirectory(tools)
61add_subdirectory(secure_fw)
62
63if(NS AND NS_EVALUATION_APP_PATH)
64    add_subdirectory(${NS_EVALUATION_APP_PATH} ${CMAKE_CURRENT_BINARY_DIR}/evaluation-app)
65elseif(NS OR TFM_S_REG_TEST OR TFM_NS_REG_TEST OR TEST_BL2 OR TEST_BL1_1 OR TEST_BL1_2)
66    add_subdirectory(${TFM_TEST_REPO_PATH} ${CMAKE_CURRENT_BINARY_DIR}/tf-m-tests)
67endif()
68
69add_subdirectory(interface)
70if(BL2)
71    add_subdirectory(bl2)
72endif()
73
74if(BL1 AND PLATFORM_DEFAULT_BL1)
75    add_subdirectory(bl1/bl1_2)
76    add_subdirectory(bl1/bl1_1)
77endif()
78
79add_subdirectory(platform)
80
81if(CRYPTO_HW_ACCELERATOR)
82    add_subdirectory(platform/ext/accelerator)
83endif()
84
85############################ Config Check ######################################
86
87include(${CMAKE_SOURCE_DIR}/config/check_config.cmake)
88
89################################################################################
90
91include(cmake/install.cmake)
92