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 | |
Ken Liu | f4a6b8a | 2021-07-27 11:25:26 +0800 | [diff] [blame] | 10 | set(TFM_VERSION 1.4.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 | |
Satish Kumar | 1ff4b95 | 2021-05-06 20:22:43 +0100 | [diff] [blame] | 74 | # Synchronise the install path variables. If CMAKE_INSTALL_PREFIX is manually |
| 75 | # set then set both to the value of that, else set both to the value of |
| 76 | # TFM_INSTALL_PATH. This has to be done after the call to `project()`. |
| 77 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 78 | set(CMAKE_INSTALL_PREFIX ${TFM_INSTALL_PATH} CACHE PATH "" FORCE) |
| 79 | else() |
| 80 | set(TFM_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} CACHE PATH "Path to which to install TF-M files" FORCE) |
| 81 | endif() |
| 82 | |
Raef Coles | a31a4b6 | 2020-11-10 09:49:17 +0000 | [diff] [blame] | 83 | ############################ Config Check ###################################### |
| 84 | |
| 85 | include(${CMAKE_SOURCE_DIR}/config/check_config.cmake) |
| 86 | |
| 87 | if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/check_config.cmake) |
| 88 | include(platform/ext/target/${TFM_PLATFORM}/check_config.cmake) |
| 89 | endif() |
| 90 | |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 91 | ################################################################################ |
| 92 | |
| 93 | add_subdirectory(lib/ext) |
Tamas Ban | b881bea | 2020-11-04 16:18:36 +0000 | [diff] [blame] | 94 | add_subdirectory(lib/fih) |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 95 | add_subdirectory(tools) |
Minos Galanakis | dff2eae | 2020-07-21 15:13:52 +0100 | [diff] [blame] | 96 | add_subdirectory(docs) |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 97 | if(NS) |
| 98 | # Set to ${TFM_TEST_REPO_PATH}/app by default |
| 99 | add_subdirectory(${TFM_APP_PATH} ${CMAKE_CURRENT_BINARY_DIR}/app) |
Kevin Peng | ca4846e | 2020-10-20 17:50:20 +0800 | [diff] [blame] | 100 | add_subdirectory(${TFM_NS_LOG_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ns_log) |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 101 | endif() |
| 102 | add_subdirectory(secure_fw) |
| 103 | add_subdirectory(interface) |
| 104 | if(BL2) |
| 105 | add_subdirectory(bl2) |
| 106 | endif() |
| 107 | add_subdirectory(platform) |
| 108 | |
David Hu | 12f2587 | 2021-08-23 14:55:46 +0800 | [diff] [blame^] | 109 | if(TFM_NS_REG_TEST OR TFM_S_REG_TEST) |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 110 | # Set to ${TFM_TEST_REPO_PATH}/test by default |
| 111 | add_subdirectory(${TFM_TEST_PATH} ${CMAKE_CURRENT_BINARY_DIR}/test) |
| 112 | endif() |
| 113 | |
| 114 | include(cmake/install.cmake) |
| 115 | |
| 116 | if(CRYPTO_HW_ACCELERATOR) |
| 117 | add_subdirectory(platform/ext/accelerator) |
| 118 | endif() |