blob: 735586ccf57a1b6021531ba8cbd11c8b215595e6 [file] [log] [blame]
Gyorgy Szing30fa9872017-12-05 01:08:47 +00001#-------------------------------------------------------------------------------
Raef Coles9ec67e62020-07-10 09:40:35 +01002# Copyright (c) 2020, 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
Minos Galanakisc9a81db2020-11-16 20:22:11 +000010set(TFM_VERSION 1.2.0)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000011
Raef Coles9ec67e62020-07-10 09:40:35 +010012############################ CONFIGURATION #####################################
13
Tamas Ban69219202020-10-27 08:13:18 +000014# Some compiler flags depend on the CPU / platform config. This include should
15# be run before the toolchain file so the compiler can be configured properly.
16if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload.cmake)
17 Message(FATAL_ERROR "Unsupported TFM_PLATFORM ${TFM_PLATFORM}")
18else()
19 include(platform/ext/target/${TFM_PLATFORM}/preload.cmake)
20endif()
21
Raef Colesfbc34cc2020-11-24 14:27:52 +000022if(TFM_SYSTEM_FP)
23 message(FATAL_ERROR "Hardware FPU is currently not supported in TF-M")
24endif()
25if(TFM_SYSTEM_MVE)
26 message(FATAL_ERROR "Hardware MVE is currently not supported in TF-M")
27endif()
28if(TFM_SYSTEM_DSP)
29 message(FATAL_ERROR "Hardware DSP is currently not supported in TF-M")
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
39# The default build type is release. If debug symbols are needed then
40# -DCMAKE_BUILD_TYPE=debug should be used (likewise with other build types)
41if (NOT CMAKE_BUILD_TYPE)
42 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type: [Debug, Release, RelWithDebInfo, MinSizeRel]" FORCE)
43endif()
44
45list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
46
47############################### Compiler configuration #########################
48
Raef Coles69817322020-10-19 14:14:14 +010049#Legacy compat option - load CMAKE_TOOLCHAIN_FILE as a TFM_TOOLCHAIN_FILE
50if (CMAKE_TOOLCHAIN_FILE)
51 message(DEPRECATION "SETTING CMAKE_TOOLCHAIN_FILE is deprecated. It has been replaced with TFM_TOOLCHAIN_FILE.")
52 message(DEPRECATION "INTERPRETING -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} as -DTFM_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
53 set(TFM_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
54 unset(CMAKE_TOOLCHAIN_FILE)
55endif()
56
Raef Coles956bd5c2020-11-03 11:30:26 +000057if (NOT IS_ABSOLUTE ${TFM_TOOLCHAIN_FILE})
58 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)")
59endif()
60
Raef Coles69817322020-10-19 14:14:14 +010061include(${TFM_TOOLCHAIN_FILE})
62set(CMAKE_PROJECT_INCLUDE_BEFORE ${CMAKE_SOURCE_DIR}/cmake/disable_compiler_detection.cmake)
63
64project("Trusted Firmware M" VERSION ${TFM_VERSION} LANGUAGES C ASM)
65tfm_toolchain_reload_compiler()
66
Raef Colesa31a4b62020-11-10 09:49:17 +000067############################ Config Check ######################################
68
69include(${CMAKE_SOURCE_DIR}/config/check_config.cmake)
70
71if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/check_config.cmake)
72 include(platform/ext/target/${TFM_PLATFORM}/check_config.cmake)
73endif()
74
Raef Coles9ec67e62020-07-10 09:40:35 +010075################################################################################
76
77add_subdirectory(lib/ext)
78add_subdirectory(tools)
Minos Galanakisdff2eae2020-07-21 15:13:52 +010079add_subdirectory(docs)
Raef Coles9ec67e62020-07-10 09:40:35 +010080if(NS)
81 # Set to ${TFM_TEST_REPO_PATH}/app by default
82 add_subdirectory(${TFM_APP_PATH} ${CMAKE_CURRENT_BINARY_DIR}/app)
Kevin Pengca4846e2020-10-20 17:50:20 +080083 add_subdirectory(${TFM_NS_LOG_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ns_log)
Raef Coles9ec67e62020-07-10 09:40:35 +010084endif()
85add_subdirectory(secure_fw)
86add_subdirectory(interface)
87if(BL2)
88 add_subdirectory(bl2)
89endif()
90add_subdirectory(platform)
91
92if(NS AND (TEST_S OR TEST_NS))
93 # Set to ${TFM_TEST_REPO_PATH}/test by default
94 add_subdirectory(${TFM_TEST_PATH} ${CMAKE_CURRENT_BINARY_DIR}/test)
95endif()
96
97include(cmake/install.cmake)
98
99if(CRYPTO_HW_ACCELERATOR)
100 add_subdirectory(platform/ext/accelerator)
101endif()