blob: 5368f8eb71b6a6c3833bca55da53496f935b8a29 [file] [log] [blame]
Gyorgy Szing30fa9872017-12-05 01:08:47 +00001#-------------------------------------------------------------------------------
Raef Coles9ec67e62020-07-10 09:40:35 +01002# Copyright (c) 2020, Arm Limited. All rights reserved.
Gyorgy Szing30fa9872017-12-05 01:08:47 +00003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
Raef Coles69817322020-10-19 14:14:14 +01008cmake_minimum_required(VERSION 3.15)
Gyorgy Szing30fa9872017-12-05 01:08:47 +00009
Raef Coles69817322020-10-19 14:14:14 +010010set(TFM_VERSION 1.1.0)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000011
Raef Coles9ec67e62020-07-10 09:40:35 +010012############################ CONFIGURATION #####################################
13
14# First load defaults.
15include(config/config_default.cmake)
16
17# Then load the build type config, overriding defaults and command line.
18string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWERCASE)
19if (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)
21endif()
22
Soby Mathew3b9e1842020-10-07 12:04:56 +010023# If configured for tests, load config specific to tests overriding defaults.
24if (TEST_PSA_API)
25 include(config/tests/config_test_psa_api.cmake)
26endif()
27
Raef Coles9ec67e62020-07-10 09:40:35 +010028# Then load the profile, overriding build type config, defaults and command
29# line.
30if (TFM_PROFILE)
31 include(config/profile/${TFM_PROFILE}.cmake)
32endif()
33
34# Then load the platform options, overriding profile, build type config,
35# defaults and command line.
36if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/config.cmake)
37 include(platform/ext/target/${TFM_PLATFORM}/config.cmake)
38endif()
39
Soby Mathew63b8e972020-10-07 12:12:44 +010040# If CRYPTO_HW_ACCELERATOR is enabled by the platform, then load the
41# corresponding config if it exists
42if (CRYPTO_HW_ACCELERATOR)
Raef Coles6b4101e2020-10-29 11:57:58 +000043 if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/accelerator/${CRYPTO_HW_ACCELERATOR_TYPE}/config.cmake)
Soby Mathew63b8e972020-10-07 12:12:44 +010044 include(platform/ext/accelerator/${CRYPTO_HW_ACCELERATOR_TYPE}/config.cmake)
45 endif()
46endif()
47
Raef Coles9ec67e62020-07-10 09:40:35 +010048# Optionally load extra config, overriding platform options, overriding profile,
49# build type config, defaults and command line.
50if (TFM_EXTRA_CONFIG_PATH)
51 include(${TFM_EXTRA_CONFIG_PATH})
52endif()
53
54list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
55
Raef Coles69817322020-10-19 14:14:14 +010056if(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\"")
59endif()
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)
63if (NOT CMAKE_BUILD_TYPE)
64 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type: [Debug, Release, RelWithDebInfo, MinSizeRel]" FORCE)
65endif()
66
67list(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.
73if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload.cmake)
74 Message(FATAL_ERROR "Unsupported TFM_PLATFORM ${TFM_PLATFORM}")
75else()
76 include(platform/ext/target/${TFM_PLATFORM}/preload.cmake)
77endif()
78
79#Legacy compat option - load CMAKE_TOOLCHAIN_FILE as a TFM_TOOLCHAIN_FILE
80if (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)
85endif()
86
87include(${TFM_TOOLCHAIN_FILE})
88set(CMAKE_PROJECT_INCLUDE_BEFORE ${CMAKE_SOURCE_DIR}/cmake/disable_compiler_detection.cmake)
89
90project("Trusted Firmware M" VERSION ${TFM_VERSION} LANGUAGES C ASM)
91tfm_toolchain_reload_compiler()
92
Raef Coles9ec67e62020-07-10 09:40:35 +010093################################################################################
94
95add_subdirectory(lib/ext)
96add_subdirectory(tools)
Minos Galanakisdff2eae2020-07-21 15:13:52 +010097add_subdirectory(docs)
Raef Coles9ec67e62020-07-10 09:40:35 +010098if(NS)
99 # Set to ${TFM_TEST_REPO_PATH}/app by default
100 add_subdirectory(${TFM_APP_PATH} ${CMAKE_CURRENT_BINARY_DIR}/app)
Kevin Pengca4846e2020-10-20 17:50:20 +0800101 add_subdirectory(${TFM_NS_LOG_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ns_log)
Raef Coles9ec67e62020-07-10 09:40:35 +0100102endif()
103add_subdirectory(secure_fw)
104add_subdirectory(interface)
105if(BL2)
106 add_subdirectory(bl2)
107endif()
108add_subdirectory(platform)
109
110if(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)
113endif()
114
115include(cmake/install.cmake)
116
117if(CRYPTO_HW_ACCELERATOR)
118 add_subdirectory(platform/ext/accelerator)
119endif()