Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Tamas Ban | b881bea | 2020-11-04 16:18:36 +0000 | [diff] [blame] | 2 | # Copyright (c) 2020-2021, Arm Limited. All rights reserved. |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 8 | cmake_minimum_required(VERSION 3.15) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 9 | |
David Hu | 3558869 | 2021-04-07 16:55:25 +0800 | [diff] [blame] | 10 | set(TFM_VERSION 1.3.0) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 11 | |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 12 | ############################ CONFIGURATION ##################################### |
| 13 | |
Øyvind Rønningstad | a9d5eac | 2021-01-22 14:21:25 +0100 | [diff] [blame] | 14 | if (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) |
| 19 | endif() |
| 20 | |
Tamas Ban | 6921920 | 2020-10-27 08:13:18 +0000 | [diff] [blame] | 21 | # 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. |
| 23 | if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload.cmake) |
| 24 | Message(FATAL_ERROR "Unsupported TFM_PLATFORM ${TFM_PLATFORM}") |
| 25 | else() |
| 26 | include(platform/ext/target/${TFM_PLATFORM}/preload.cmake) |
| 27 | endif() |
| 28 | |
Raef Coles | fbc34cc | 2020-11-24 14:27:52 +0000 | [diff] [blame] | 29 | if(TFM_SYSTEM_FP) |
| 30 | message(FATAL_ERROR "Hardware FPU is currently not supported in TF-M") |
| 31 | endif() |
| 32 | if(TFM_SYSTEM_MVE) |
| 33 | message(FATAL_ERROR "Hardware MVE is currently not supported in TF-M") |
| 34 | endif() |
| 35 | if(TFM_SYSTEM_DSP) |
| 36 | message(FATAL_ERROR "Hardware DSP is currently not supported in TF-M") |
| 37 | endif() |
| 38 | |
Raef Coles | 958aeef | 2020-10-08 12:12:58 +0100 | [diff] [blame] | 39 | include(config/set_config.cmake) |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 40 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 41 | if(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\"") |
| 44 | endif() |
| 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) |
| 48 | if (NOT CMAKE_BUILD_TYPE) |
| 49 | set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type: [Debug, Release, RelWithDebInfo, MinSizeRel]" FORCE) |
| 50 | endif() |
| 51 | |
| 52 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) |
| 53 | |
| 54 | ############################### Compiler configuration ######################### |
| 55 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 56 | #Legacy compat option - load CMAKE_TOOLCHAIN_FILE as a TFM_TOOLCHAIN_FILE |
| 57 | if (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) |
| 62 | endif() |
| 63 | |
Raef Coles | 956bd5c | 2020-11-03 11:30:26 +0000 | [diff] [blame] | 64 | if (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)") |
| 66 | endif() |
| 67 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 68 | include(${TFM_TOOLCHAIN_FILE}) |
| 69 | set(CMAKE_PROJECT_INCLUDE_BEFORE ${CMAKE_SOURCE_DIR}/cmake/disable_compiler_detection.cmake) |
| 70 | |
| 71 | project("Trusted Firmware M" VERSION ${TFM_VERSION} LANGUAGES C ASM) |
| 72 | tfm_toolchain_reload_compiler() |
| 73 | |
Raef Coles | a31a4b6 | 2020-11-10 09:49:17 +0000 | [diff] [blame] | 74 | ############################ Config Check ###################################### |
| 75 | |
| 76 | include(${CMAKE_SOURCE_DIR}/config/check_config.cmake) |
| 77 | |
| 78 | if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/check_config.cmake) |
| 79 | include(platform/ext/target/${TFM_PLATFORM}/check_config.cmake) |
| 80 | endif() |
| 81 | |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 82 | ################################################################################ |
| 83 | |
| 84 | add_subdirectory(lib/ext) |
Tamas Ban | b881bea | 2020-11-04 16:18:36 +0000 | [diff] [blame] | 85 | add_subdirectory(lib/fih) |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 86 | add_subdirectory(tools) |
Minos Galanakis | dff2eae | 2020-07-21 15:13:52 +0100 | [diff] [blame] | 87 | add_subdirectory(docs) |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 88 | if(NS) |
| 89 | # Set to ${TFM_TEST_REPO_PATH}/app by default |
| 90 | add_subdirectory(${TFM_APP_PATH} ${CMAKE_CURRENT_BINARY_DIR}/app) |
Kevin Peng | ca4846e | 2020-10-20 17:50:20 +0800 | [diff] [blame] | 91 | add_subdirectory(${TFM_NS_LOG_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ns_log) |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 92 | endif() |
| 93 | add_subdirectory(secure_fw) |
| 94 | add_subdirectory(interface) |
| 95 | if(BL2) |
| 96 | add_subdirectory(bl2) |
| 97 | endif() |
| 98 | add_subdirectory(platform) |
| 99 | |
| 100 | if(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) |
| 103 | endif() |
| 104 | |
| 105 | include(cmake/install.cmake) |
| 106 | |
| 107 | if(CRYPTO_HW_ACCELERATOR) |
| 108 | add_subdirectory(platform/ext/accelerator) |
| 109 | endif() |