blob: be3bf75f73c449593e75da9e73305ca0cc0fc467 [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.
Gyorgy Szing30fa9872017-12-05 01:08:47 +00003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
Raef Coles69817322020-10-19 14:14:14 +01008cmake_minimum_required(VERSION 3.15)
Gyorgy Szing30fa9872017-12-05 01:08:47 +00009
Anton Komlevceafd012021-10-11 23:21:11 +010010include(version.cmake)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000011
Raef Coles9ec67e62020-07-10 09:40:35 +010012############################ CONFIGURATION #####################################
13
Øyvind Rønningstada9d5eac2021-01-22 14:21:25 +010014if (IS_ABSOLUTE "${TFM_PLATFORM}")
15 file(RELATIVE_PATH TFM_PLATFORM_RELATIVE_PATH
16 "${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target"
17 ${TFM_PLATFORM})
18 set(TFM_PLATFORM "${TFM_PLATFORM_RELATIVE_PATH}" CACHE STRING "Target platform set as an absolute path." FORCE)
19endif()
20
Tamas Ban69219202020-10-27 08:13:18 +000021# Some compiler flags depend on the CPU / platform config. This include should
22# be run before the toolchain file so the compiler can be configured properly.
23if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload.cmake)
24 Message(FATAL_ERROR "Unsupported TFM_PLATFORM ${TFM_PLATFORM}")
25else()
26 include(platform/ext/target/${TFM_PLATFORM}/preload.cmake)
27endif()
28
Raef Colesfbc34cc2020-11-24 14:27:52 +000029if(TFM_SYSTEM_MVE)
30 message(FATAL_ERROR "Hardware MVE is currently not supported in TF-M")
31endif()
32if(TFM_SYSTEM_DSP)
33 message(FATAL_ERROR "Hardware DSP is currently not supported in TF-M")
34endif()
35
Jianliang Shen89cdb352021-11-03 10:27:12 +080036# The default build type is release. If debug symbols are needed then
37# -DCMAKE_BUILD_TYPE=debug should be used (likewise with other build types)
38if (NOT CMAKE_BUILD_TYPE)
39 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type: [Debug, Release, RelWithDebInfo, MinSizeRel]" FORCE)
40endif()
41
Raef Coles958aeef2020-10-08 12:12:58 +010042include(config/set_config.cmake)
Raef Coles9ec67e62020-07-10 09:40:35 +010043
Raef Coles69817322020-10-19 14:14:14 +010044if(NOT ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" AND
45 NOT ${CMAKE_GENERATOR} STREQUAL "Ninja")
46 Message(FATAL_ERROR "Unsupported generator ${CMAKE_GENERATOR}. Hint: Try -G\"Unix Makefiles\"")
47endif()
48
Raef Coles69817322020-10-19 14:14:14 +010049list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
50
51############################### Compiler configuration #########################
52
Raef Coles69817322020-10-19 14:14:14 +010053#Legacy compat option - load CMAKE_TOOLCHAIN_FILE as a TFM_TOOLCHAIN_FILE
54if (CMAKE_TOOLCHAIN_FILE)
55 message(DEPRECATION "SETTING CMAKE_TOOLCHAIN_FILE is deprecated. It has been replaced with TFM_TOOLCHAIN_FILE.")
56 message(DEPRECATION "INTERPRETING -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} as -DTFM_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
57 set(TFM_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
58 unset(CMAKE_TOOLCHAIN_FILE)
59endif()
60
Raef Coles956bd5c2020-11-03 11:30:26 +000061if (NOT IS_ABSOLUTE ${TFM_TOOLCHAIN_FILE})
62 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)")
63endif()
64
Raef Coles69817322020-10-19 14:14:14 +010065include(${TFM_TOOLCHAIN_FILE})
66set(CMAKE_PROJECT_INCLUDE_BEFORE ${CMAKE_SOURCE_DIR}/cmake/disable_compiler_detection.cmake)
67
68project("Trusted Firmware M" VERSION ${TFM_VERSION} LANGUAGES C ASM)
69tfm_toolchain_reload_compiler()
70
Satish Kumar1ff4b952021-05-06 20:22:43 +010071# Synchronise the install path variables. If CMAKE_INSTALL_PREFIX is manually
72# set then set both to the value of that, else set both to the value of
73# TFM_INSTALL_PATH. This has to be done after the call to `project()`.
74if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
75 set(CMAKE_INSTALL_PREFIX ${TFM_INSTALL_PATH} CACHE PATH "" FORCE)
76else()
77 set(TFM_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} CACHE PATH "Path to which to install TF-M files" FORCE)
78endif()
79
Raef Colesa31a4b62020-11-10 09:49:17 +000080############################ Config Check ######################################
81
82include(${CMAKE_SOURCE_DIR}/config/check_config.cmake)
83
84if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/check_config.cmake)
85 include(platform/ext/target/${TFM_PLATFORM}/check_config.cmake)
86endif()
87
Raef Coles9ec67e62020-07-10 09:40:35 +010088################################################################################
89
90add_subdirectory(lib/ext)
Tamas Banb881bea2020-11-04 16:18:36 +000091add_subdirectory(lib/fih)
Raef Coles9ec67e62020-07-10 09:40:35 +010092add_subdirectory(tools)
Raef Coles9ec67e62020-07-10 09:40:35 +010093add_subdirectory(secure_fw)
Raef Colesd97a7e72021-12-10 14:58:06 +000094
95if(NS OR TFM_S_REG_TEST OR TFM_NS_REG_TEST)
96 add_subdirectory(${TFM_TEST_REPO_PATH} ${CMAKE_CURRENT_BINARY_DIR}/tf-m-tests)
97endif()
98
Raef Coles9ec67e62020-07-10 09:40:35 +010099add_subdirectory(interface)
100if(BL2)
101 add_subdirectory(bl2)
102endif()
Raef Coles9ec67e62020-07-10 09:40:35 +0100103
Raef Colesd97a7e72021-12-10 14:58:06 +0000104add_subdirectory(platform)
Raef Coles9ec67e62020-07-10 09:40:35 +0100105
106include(cmake/install.cmake)
107
108if(CRYPTO_HW_ACCELERATOR)
109 add_subdirectory(platform/ext/accelerator)
110endif()