blob: b49456a3a50b36b3a6f5d754e1fa4658ef7448e7 [file] [log] [blame]
Gyorgy Szing30fa9872017-12-05 01:08:47 +00001#-------------------------------------------------------------------------------
Raef Colesd97a7e72021-12-10 14:58:06 +00002# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
Chris Brand9edf0812022-07-05 14:18:42 -07003# Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
4# or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
Gyorgy Szing30fa9872017-12-05 01:08:47 +00005#
6# SPDX-License-Identifier: BSD-3-Clause
7#
8#-------------------------------------------------------------------------------
9
Raef Coles69817322020-10-19 14:14:14 +010010cmake_minimum_required(VERSION 3.15)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000011
Anton Komlev2d2a6fc2022-02-20 15:47:53 +000012include(cmake/version.cmake)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000013
Raef Coles9ec67e62020-07-10 09:40:35 +010014############################ CONFIGURATION #####################################
15
Jianliang Shen1c4f1c22022-03-07 15:56:06 +080016# Configure TFM_PLATFORM
17include(${CMAKE_SOURCE_DIR}/config/tfm_platform.cmake)
Tamas Ban69219202020-10-27 08:13:18 +000018
Raef Colesfbc34cc2020-11-24 14:27:52 +000019if(TFM_SYSTEM_MVE)
20 message(FATAL_ERROR "Hardware MVE is currently not supported in TF-M")
21endif()
22if(TFM_SYSTEM_DSP)
23 message(FATAL_ERROR "Hardware DSP is currently not supported in TF-M")
24endif()
25
Jianliang Shen89cdb352021-11-03 10:27:12 +080026# The default build type is release. If debug symbols are needed then
27# -DCMAKE_BUILD_TYPE=debug should be used (likewise with other build types)
28if (NOT CMAKE_BUILD_TYPE)
29 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type: [Debug, Release, RelWithDebInfo, MinSizeRel]" FORCE)
30endif()
31
Raef Coles958aeef2020-10-08 12:12:58 +010032include(config/set_config.cmake)
Raef Coles9ec67e62020-07-10 09:40:35 +010033
Raef Coles69817322020-10-19 14:14:14 +010034if(NOT ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" AND
35 NOT ${CMAKE_GENERATOR} STREQUAL "Ninja")
36 Message(FATAL_ERROR "Unsupported generator ${CMAKE_GENERATOR}. Hint: Try -G\"Unix Makefiles\"")
37endif()
38
David Hueeb61d22022-07-29 15:12:25 +020039list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
40
Raef Coles69817322020-10-19 14:14:14 +010041############################### Compiler configuration #########################
42
Raef Coles69817322020-10-19 14:14:14 +010043#Legacy compat option - load CMAKE_TOOLCHAIN_FILE as a TFM_TOOLCHAIN_FILE
44if (CMAKE_TOOLCHAIN_FILE)
45 message(DEPRECATION "SETTING CMAKE_TOOLCHAIN_FILE is deprecated. It has been replaced with TFM_TOOLCHAIN_FILE.")
46 message(DEPRECATION "INTERPRETING -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} as -DTFM_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
47 set(TFM_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
48 unset(CMAKE_TOOLCHAIN_FILE)
49endif()
50
Raef Coles956bd5c2020-11-03 11:30:26 +000051if (NOT IS_ABSOLUTE ${TFM_TOOLCHAIN_FILE})
52 message(FATAL_ERROR "SETTING CMAKE_TOOLCHAIN_FILE no longer accepts relative paths. Please supply an absolute path or instead use TFM_TOOLCHAIN_FILE (which does accept relative paths)")
53endif()
54
Raef Coles69817322020-10-19 14:14:14 +010055include(${TFM_TOOLCHAIN_FILE})
56set(CMAKE_PROJECT_INCLUDE_BEFORE ${CMAKE_SOURCE_DIR}/cmake/disable_compiler_detection.cmake)
57
58project("Trusted Firmware M" VERSION ${TFM_VERSION} LANGUAGES C ASM)
59tfm_toolchain_reload_compiler()
60
Satish Kumar1ff4b952021-05-06 20:22:43 +010061# Synchronise the install path variables. If CMAKE_INSTALL_PREFIX is manually
62# set then set both to the value of that, else set both to the value of
63# TFM_INSTALL_PATH. This has to be done after the call to `project()`.
64if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
65 set(CMAKE_INSTALL_PREFIX ${TFM_INSTALL_PATH} CACHE PATH "" FORCE)
66else()
67 set(TFM_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} CACHE PATH "Path to which to install TF-M files" FORCE)
68endif()
69
Raef Colesa31a4b62020-11-10 09:49:17 +000070############################ Config Check ######################################
71
72include(${CMAKE_SOURCE_DIR}/config/check_config.cmake)
73
Raef Coles9ec67e62020-07-10 09:40:35 +010074################################################################################
75
76add_subdirectory(lib/ext)
Tamas Banb881bea2020-11-04 16:18:36 +000077add_subdirectory(lib/fih)
Raef Coles9ec67e62020-07-10 09:40:35 +010078add_subdirectory(tools)
David Hu1a2d4832022-01-18 14:42:04 +080079add_subdirectory(secure_fw)
Raef Colesd97a7e72021-12-10 14:58:06 +000080
Gabor Abonyie3222f92022-04-07 13:53:03 +020081if(NS AND NS_EVALUATION_APP_PATH)
82 add_subdirectory(${NS_EVALUATION_APP_PATH} ${CMAKE_CURRENT_BINARY_DIR}/evaluation-app)
83elseif(NS OR TFM_S_REG_TEST OR TFM_NS_REG_TEST OR TEST_BL2 OR TEST_BL1_1 OR TEST_BL1_2)
Raef Coles38675932022-01-18 12:56:40 +000084 add_subdirectory(${TFM_TEST_REPO_PATH} ${CMAKE_CURRENT_BINARY_DIR}/tf-m-tests)
85endif()
86
Raef Coles9ec67e62020-07-10 09:40:35 +010087add_subdirectory(interface)
88if(BL2)
89 add_subdirectory(bl2)
90endif()
Raef Coles9ec67e62020-07-10 09:40:35 +010091
Raef Coles15a37f82021-12-07 15:59:14 +000092if(BL1 AND PLATFORM_DEFAULT_BL1)
93 add_subdirectory(bl1/bl1_2)
94 add_subdirectory(bl1/bl1_1)
95endif()
96
Raef Colesd97a7e72021-12-10 14:58:06 +000097add_subdirectory(platform)
Raef Coles9ec67e62020-07-10 09:40:35 +010098
Raef Coles9ec67e62020-07-10 09:40:35 +010099if(CRYPTO_HW_ACCELERATOR)
100 add_subdirectory(platform/ext/accelerator)
101endif()
Chris Brand9edf0812022-07-05 14:18:42 -0700102
103include(cmake/install.cmake)