blob: 162db66fdb9d7bc78496a42ba7f92475be5bff0a [file] [log] [blame]
Gyorgy Szing30fa9872017-12-05 01:08:47 +00001#-------------------------------------------------------------------------------
Tamas Banb881bea2020-11-04 16:18:36 +00002# Copyright (c) 2020-2021, 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
Ken Liuf4a6b8a2021-07-27 11:25:26 +080010set(TFM_VERSION 1.4.0)
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_FP)
30 message(FATAL_ERROR "Hardware FPU is currently not supported in TF-M")
31endif()
32if(TFM_SYSTEM_MVE)
33 message(FATAL_ERROR "Hardware MVE is currently not supported in TF-M")
34endif()
35if(TFM_SYSTEM_DSP)
36 message(FATAL_ERROR "Hardware DSP is currently not supported in TF-M")
37endif()
38
Raef Coles958aeef2020-10-08 12:12:58 +010039include(config/set_config.cmake)
Raef Coles9ec67e62020-07-10 09:40:35 +010040
Raef Coles69817322020-10-19 14:14:14 +010041if(NOT ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" AND
42 NOT ${CMAKE_GENERATOR} STREQUAL "Ninja")
43 Message(FATAL_ERROR "Unsupported generator ${CMAKE_GENERATOR}. Hint: Try -G\"Unix Makefiles\"")
44endif()
45
46# The default build type is release. If debug symbols are needed then
47# -DCMAKE_BUILD_TYPE=debug should be used (likewise with other build types)
48if (NOT CMAKE_BUILD_TYPE)
49 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type: [Debug, Release, RelWithDebInfo, MinSizeRel]" FORCE)
50endif()
51
52list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
53
54############################### Compiler configuration #########################
55
Raef Coles69817322020-10-19 14:14:14 +010056#Legacy compat option - load CMAKE_TOOLCHAIN_FILE as a TFM_TOOLCHAIN_FILE
57if (CMAKE_TOOLCHAIN_FILE)
58 message(DEPRECATION "SETTING CMAKE_TOOLCHAIN_FILE is deprecated. It has been replaced with TFM_TOOLCHAIN_FILE.")
59 message(DEPRECATION "INTERPRETING -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} as -DTFM_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
60 set(TFM_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
61 unset(CMAKE_TOOLCHAIN_FILE)
62endif()
63
Raef Coles956bd5c2020-11-03 11:30:26 +000064if (NOT IS_ABSOLUTE ${TFM_TOOLCHAIN_FILE})
65 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)")
66endif()
67
Raef Coles69817322020-10-19 14:14:14 +010068include(${TFM_TOOLCHAIN_FILE})
69set(CMAKE_PROJECT_INCLUDE_BEFORE ${CMAKE_SOURCE_DIR}/cmake/disable_compiler_detection.cmake)
70
71project("Trusted Firmware M" VERSION ${TFM_VERSION} LANGUAGES C ASM)
72tfm_toolchain_reload_compiler()
73
Raef Colesa31a4b62020-11-10 09:49:17 +000074############################ Config Check ######################################
75
76include(${CMAKE_SOURCE_DIR}/config/check_config.cmake)
77
78if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/check_config.cmake)
79 include(platform/ext/target/${TFM_PLATFORM}/check_config.cmake)
80endif()
81
Raef Coles9ec67e62020-07-10 09:40:35 +010082################################################################################
83
84add_subdirectory(lib/ext)
Tamas Banb881bea2020-11-04 16:18:36 +000085add_subdirectory(lib/fih)
Raef Coles9ec67e62020-07-10 09:40:35 +010086add_subdirectory(tools)
Minos Galanakisdff2eae2020-07-21 15:13:52 +010087add_subdirectory(docs)
Raef Coles9ec67e62020-07-10 09:40:35 +010088if(NS)
89 # Set to ${TFM_TEST_REPO_PATH}/app by default
90 add_subdirectory(${TFM_APP_PATH} ${CMAKE_CURRENT_BINARY_DIR}/app)
Kevin Pengca4846e2020-10-20 17:50:20 +080091 add_subdirectory(${TFM_NS_LOG_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ns_log)
Raef Coles9ec67e62020-07-10 09:40:35 +010092endif()
93add_subdirectory(secure_fw)
94add_subdirectory(interface)
95if(BL2)
96 add_subdirectory(bl2)
97endif()
98add_subdirectory(platform)
99
100if(NS AND (TEST_S OR TEST_NS))
101 # Set to ${TFM_TEST_REPO_PATH}/test by default
102 add_subdirectory(${TFM_TEST_PATH} ${CMAKE_CURRENT_BINARY_DIR}/test)
103endif()
104
105include(cmake/install.cmake)
106
107if(CRYPTO_HW_ACCELERATOR)
108 add_subdirectory(platform/ext/accelerator)
109endif()