Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Raef Coles | d97a7e7 | 2021-12-10 14:58:06 +0000 | [diff] [blame] | 2 | # Copyright (c) 2020-2022, 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 | |
Anton Komlev | 2d2a6fc | 2022-02-20 15:47:53 +0000 | [diff] [blame] | 10 | include(cmake/version.cmake) |
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 | |
Jianliang Shen | 1c4f1c2 | 2022-03-07 15:56:06 +0800 | [diff] [blame] | 14 | # Configure TFM_PLATFORM |
| 15 | include(${CMAKE_SOURCE_DIR}/config/tfm_platform.cmake) |
Tamas Ban | 6921920 | 2020-10-27 08:13:18 +0000 | [diff] [blame] | 16 | |
Raef Coles | fbc34cc | 2020-11-24 14:27:52 +0000 | [diff] [blame] | 17 | if(TFM_SYSTEM_MVE) |
| 18 | message(FATAL_ERROR "Hardware MVE is currently not supported in TF-M") |
| 19 | endif() |
| 20 | if(TFM_SYSTEM_DSP) |
| 21 | message(FATAL_ERROR "Hardware DSP is currently not supported in TF-M") |
| 22 | endif() |
| 23 | |
Jianliang Shen | 89cdb35 | 2021-11-03 10:27:12 +0800 | [diff] [blame] | 24 | # The default build type is release. If debug symbols are needed then |
| 25 | # -DCMAKE_BUILD_TYPE=debug should be used (likewise with other build types) |
| 26 | if (NOT CMAKE_BUILD_TYPE) |
| 27 | set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type: [Debug, Release, RelWithDebInfo, MinSizeRel]" FORCE) |
| 28 | endif() |
| 29 | |
Raef Coles | 958aeef | 2020-10-08 12:12:58 +0100 | [diff] [blame] | 30 | include(config/set_config.cmake) |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 31 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 32 | if(NOT ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" AND |
| 33 | NOT ${CMAKE_GENERATOR} STREQUAL "Ninja") |
| 34 | Message(FATAL_ERROR "Unsupported generator ${CMAKE_GENERATOR}. Hint: Try -G\"Unix Makefiles\"") |
| 35 | endif() |
| 36 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 37 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) |
| 38 | |
| 39 | ############################### Compiler configuration ######################### |
| 40 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 41 | #Legacy compat option - load CMAKE_TOOLCHAIN_FILE as a TFM_TOOLCHAIN_FILE |
| 42 | if (CMAKE_TOOLCHAIN_FILE) |
| 43 | message(DEPRECATION "SETTING CMAKE_TOOLCHAIN_FILE is deprecated. It has been replaced with TFM_TOOLCHAIN_FILE.") |
| 44 | message(DEPRECATION "INTERPRETING -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} as -DTFM_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") |
| 45 | set(TFM_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE}) |
| 46 | unset(CMAKE_TOOLCHAIN_FILE) |
| 47 | endif() |
| 48 | |
Raef Coles | 956bd5c | 2020-11-03 11:30:26 +0000 | [diff] [blame] | 49 | if (NOT IS_ABSOLUTE ${TFM_TOOLCHAIN_FILE}) |
| 50 | 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)") |
| 51 | endif() |
| 52 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 53 | include(${TFM_TOOLCHAIN_FILE}) |
| 54 | set(CMAKE_PROJECT_INCLUDE_BEFORE ${CMAKE_SOURCE_DIR}/cmake/disable_compiler_detection.cmake) |
| 55 | |
| 56 | project("Trusted Firmware M" VERSION ${TFM_VERSION} LANGUAGES C ASM) |
| 57 | tfm_toolchain_reload_compiler() |
| 58 | |
Satish Kumar | 1ff4b95 | 2021-05-06 20:22:43 +0100 | [diff] [blame] | 59 | # Synchronise the install path variables. If CMAKE_INSTALL_PREFIX is manually |
| 60 | # set then set both to the value of that, else set both to the value of |
| 61 | # TFM_INSTALL_PATH. This has to be done after the call to `project()`. |
| 62 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 63 | set(CMAKE_INSTALL_PREFIX ${TFM_INSTALL_PATH} CACHE PATH "" FORCE) |
| 64 | else() |
| 65 | set(TFM_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} CACHE PATH "Path to which to install TF-M files" FORCE) |
| 66 | endif() |
| 67 | |
Raef Coles | a31a4b6 | 2020-11-10 09:49:17 +0000 | [diff] [blame] | 68 | ############################ Config Check ###################################### |
| 69 | |
| 70 | include(${CMAKE_SOURCE_DIR}/config/check_config.cmake) |
| 71 | |
| 72 | if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/check_config.cmake) |
| 73 | include(platform/ext/target/${TFM_PLATFORM}/check_config.cmake) |
| 74 | endif() |
| 75 | |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 76 | ################################################################################ |
| 77 | |
| 78 | add_subdirectory(lib/ext) |
Tamas Ban | b881bea | 2020-11-04 16:18:36 +0000 | [diff] [blame] | 79 | add_subdirectory(lib/fih) |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 80 | add_subdirectory(tools) |
David Hu | 1a2d483 | 2022-01-18 14:42:04 +0800 | [diff] [blame] | 81 | add_subdirectory(secure_fw) |
Raef Coles | d97a7e7 | 2021-12-10 14:58:06 +0000 | [diff] [blame] | 82 | |
Gabor Abonyi | e3222f9 | 2022-04-07 13:53:03 +0200 | [diff] [blame] | 83 | if(NS AND NS_EVALUATION_APP_PATH) |
| 84 | add_subdirectory(${NS_EVALUATION_APP_PATH} ${CMAKE_CURRENT_BINARY_DIR}/evaluation-app) |
| 85 | elseif(NS OR TFM_S_REG_TEST OR TFM_NS_REG_TEST OR TEST_BL2 OR TEST_BL1_1 OR TEST_BL1_2) |
Raef Coles | 3867593 | 2022-01-18 12:56:40 +0000 | [diff] [blame] | 86 | add_subdirectory(${TFM_TEST_REPO_PATH} ${CMAKE_CURRENT_BINARY_DIR}/tf-m-tests) |
| 87 | endif() |
| 88 | |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 89 | add_subdirectory(interface) |
| 90 | if(BL2) |
| 91 | add_subdirectory(bl2) |
| 92 | endif() |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 93 | |
Raef Coles | 15a37f8 | 2021-12-07 15:59:14 +0000 | [diff] [blame] | 94 | if(BL1 AND PLATFORM_DEFAULT_BL1) |
| 95 | add_subdirectory(bl1/bl1_2) |
| 96 | add_subdirectory(bl1/bl1_1) |
| 97 | endif() |
| 98 | |
Raef Coles | d97a7e7 | 2021-12-10 14:58:06 +0000 | [diff] [blame] | 99 | add_subdirectory(platform) |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 100 | |
| 101 | include(cmake/install.cmake) |
| 102 | |
| 103 | if(CRYPTO_HW_ACCELERATOR) |
| 104 | add_subdirectory(platform/ext/accelerator) |
| 105 | endif() |