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