Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 2 | # Copyright (c) 2020, 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 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame^] | 10 | set(TFM_VERSION 1.1.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 | |
| 14 | # First load defaults. |
| 15 | include(config/config_default.cmake) |
| 16 | |
| 17 | # Then load the build type config, overriding defaults and command line. |
| 18 | string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWERCASE) |
| 19 | if (EXISTS ${CMAKE_SOURCE_DIR}/config/build_type/${CMAKE_BUILD_TYPE_LOWERCASE}.cmake) |
| 20 | include(${CMAKE_SOURCE_DIR}/config/build_type/${CMAKE_BUILD_TYPE_LOWERCASE}.cmake) |
| 21 | endif() |
| 22 | |
Soby Mathew | 3b9e184 | 2020-10-07 12:04:56 +0100 | [diff] [blame] | 23 | # If configured for tests, load config specific to tests overriding defaults. |
| 24 | if (TEST_PSA_API) |
| 25 | include(config/tests/config_test_psa_api.cmake) |
| 26 | endif() |
| 27 | |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 28 | # Then load the profile, overriding build type config, defaults and command |
| 29 | # line. |
| 30 | if (TFM_PROFILE) |
| 31 | include(config/profile/${TFM_PROFILE}.cmake) |
| 32 | endif() |
| 33 | |
| 34 | # Then load the platform options, overriding profile, build type config, |
| 35 | # defaults and command line. |
| 36 | if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/config.cmake) |
| 37 | include(platform/ext/target/${TFM_PLATFORM}/config.cmake) |
| 38 | endif() |
| 39 | |
Soby Mathew | 63b8e97 | 2020-10-07 12:12:44 +0100 | [diff] [blame] | 40 | # If CRYPTO_HW_ACCELERATOR is enabled by the platform, then load the |
| 41 | # corresponding config if it exists |
| 42 | if (CRYPTO_HW_ACCELERATOR) |
Raef Coles | 6b4101e | 2020-10-29 11:57:58 +0000 | [diff] [blame] | 43 | if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/accelerator/${CRYPTO_HW_ACCELERATOR_TYPE}/config.cmake) |
Soby Mathew | 63b8e97 | 2020-10-07 12:12:44 +0100 | [diff] [blame] | 44 | include(platform/ext/accelerator/${CRYPTO_HW_ACCELERATOR_TYPE}/config.cmake) |
| 45 | endif() |
| 46 | endif() |
| 47 | |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 48 | # Optionally load extra config, overriding platform options, overriding profile, |
| 49 | # build type config, defaults and command line. |
| 50 | if (TFM_EXTRA_CONFIG_PATH) |
| 51 | include(${TFM_EXTRA_CONFIG_PATH}) |
| 52 | endif() |
| 53 | |
| 54 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) |
| 55 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame^] | 56 | if(NOT ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" AND |
| 57 | NOT ${CMAKE_GENERATOR} STREQUAL "Ninja") |
| 58 | Message(FATAL_ERROR "Unsupported generator ${CMAKE_GENERATOR}. Hint: Try -G\"Unix Makefiles\"") |
| 59 | endif() |
| 60 | |
| 61 | # The default build type is release. If debug symbols are needed then |
| 62 | # -DCMAKE_BUILD_TYPE=debug should be used (likewise with other build types) |
| 63 | if (NOT CMAKE_BUILD_TYPE) |
| 64 | set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type: [Debug, Release, RelWithDebInfo, MinSizeRel]" FORCE) |
| 65 | endif() |
| 66 | |
| 67 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) |
| 68 | |
| 69 | ############################### Compiler configuration ######################### |
| 70 | |
| 71 | # Some compiler flags depend on the CPU / platform config. This include should |
| 72 | # be run before the toolchain file so the compiler can be configured properly. |
| 73 | if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload.cmake) |
| 74 | Message(FATAL_ERROR "Unsupported TFM_PLATFORM ${TFM_PLATFORM}") |
| 75 | else() |
| 76 | include(platform/ext/target/${TFM_PLATFORM}/preload.cmake) |
| 77 | endif() |
| 78 | |
| 79 | #Legacy compat option - load CMAKE_TOOLCHAIN_FILE as a TFM_TOOLCHAIN_FILE |
| 80 | if (CMAKE_TOOLCHAIN_FILE) |
| 81 | message(DEPRECATION "SETTING CMAKE_TOOLCHAIN_FILE is deprecated. It has been replaced with TFM_TOOLCHAIN_FILE.") |
| 82 | message(DEPRECATION "INTERPRETING -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} as -DTFM_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") |
| 83 | set(TFM_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE}) |
| 84 | unset(CMAKE_TOOLCHAIN_FILE) |
| 85 | endif() |
| 86 | |
| 87 | include(${TFM_TOOLCHAIN_FILE}) |
| 88 | set(CMAKE_PROJECT_INCLUDE_BEFORE ${CMAKE_SOURCE_DIR}/cmake/disable_compiler_detection.cmake) |
| 89 | |
| 90 | project("Trusted Firmware M" VERSION ${TFM_VERSION} LANGUAGES C ASM) |
| 91 | tfm_toolchain_reload_compiler() |
| 92 | |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 93 | ################################################################################ |
| 94 | |
| 95 | add_subdirectory(lib/ext) |
| 96 | add_subdirectory(tools) |
Minos Galanakis | dff2eae | 2020-07-21 15:13:52 +0100 | [diff] [blame] | 97 | add_subdirectory(docs) |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 98 | if(NS) |
| 99 | # Set to ${TFM_TEST_REPO_PATH}/app by default |
| 100 | add_subdirectory(${TFM_APP_PATH} ${CMAKE_CURRENT_BINARY_DIR}/app) |
Kevin Peng | ca4846e | 2020-10-20 17:50:20 +0800 | [diff] [blame] | 101 | add_subdirectory(${TFM_NS_LOG_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ns_log) |
Raef Coles | 9ec67e6 | 2020-07-10 09:40:35 +0100 | [diff] [blame] | 102 | endif() |
| 103 | add_subdirectory(secure_fw) |
| 104 | add_subdirectory(interface) |
| 105 | if(BL2) |
| 106 | add_subdirectory(bl2) |
| 107 | endif() |
| 108 | add_subdirectory(platform) |
| 109 | |
| 110 | if(NS AND (TEST_S OR TEST_NS)) |
| 111 | # Set to ${TFM_TEST_REPO_PATH}/test by default |
| 112 | add_subdirectory(${TFM_TEST_PATH} ${CMAKE_CURRENT_BINARY_DIR}/test) |
| 113 | endif() |
| 114 | |
| 115 | include(cmake/install.cmake) |
| 116 | |
| 117 | if(CRYPTO_HW_ACCELERATOR) |
| 118 | add_subdirectory(platform/ext/accelerator) |
| 119 | endif() |