blob: fb6e840484f341b6dcfea9f06f4cc5124cdf1ee0 [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 Coles9ec67e62020-07-10 09:40:35 +01008cmake_minimum_required(VERSION 3.13)
Gyorgy Szing30fa9872017-12-05 01:08:47 +00009
Raef Coles9ec67e62020-07-10 09:40:35 +010010project("Trusted Firmware M" VERSION 1.1.0 LANGUAGES C ASM)
11set(TFM_VERSION ${PROJECT_VERSION})
Gyorgy Szing30fa9872017-12-05 01:08:47 +000012
Raef Coles6e8f83d2020-09-28 10:44:06 +010013if(NOT TFM_CMAKE_TOOLCHAIN_FILE_LOADED)
14 Message(FATAL_ERROR "Cmake toolchain file not set.")
15endif()
16
17if(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\"")
20endif()
21
Raef Coles9ec67e62020-07-10 09:40:35 +010022# 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 Coles6e8f83d2020-09-28 10:44:06 +010024if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload.cmake)
25 Message(FATAL_ERROR "Unsupported TFM_PLATFORM ${TFM_PLATFORM}")
26else()
27 include(platform/ext/target/${TFM_PLATFORM}/preload.cmake)
28endif()
Raef Coles9ec67e62020-07-10 09:40:35 +010029
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)
32if (NOT CMAKE_BUILD_TYPE)
33 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type: [Debug, Release, RelWithDebInfo, MinSizeRel]" FORCE)
David Vinczec3e313a2020-01-06 17:31:11 +010034endif()
Gyorgy Szing30fa9872017-12-05 01:08:47 +000035
Raef Coles9ec67e62020-07-10 09:40:35 +010036############################ CONFIGURATION #####################################
37
38# First load defaults.
39include(config/config_default.cmake)
40
41# Then load the build type config, overriding defaults and command line.
42string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWERCASE)
43if (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)
45endif()
46
Soby Mathew3b9e1842020-10-07 12:04:56 +010047# If configured for tests, load config specific to tests overriding defaults.
48if (TEST_PSA_API)
49 include(config/tests/config_test_psa_api.cmake)
50endif()
51
Raef Coles9ec67e62020-07-10 09:40:35 +010052# Then load the profile, overriding build type config, defaults and command
53# line.
54if (TFM_PROFILE)
55 include(config/profile/${TFM_PROFILE}.cmake)
56endif()
57
58# Then load the platform options, overriding profile, build type config,
59# defaults and command line.
60if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/config.cmake)
61 include(platform/ext/target/${TFM_PLATFORM}/config.cmake)
62endif()
63
Soby Mathew63b8e972020-10-07 12:12:44 +010064# If CRYPTO_HW_ACCELERATOR is enabled by the platform, then load the
65# corresponding config if it exists
66if (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()
70endif()
71
Raef Coles9ec67e62020-07-10 09:40:35 +010072# Optionally load extra config, overriding platform options, overriding profile,
73# build type config, defaults and command line.
74if (TFM_EXTRA_CONFIG_PATH)
75 include(${TFM_EXTRA_CONFIG_PATH})
76endif()
77
78list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
79
80################################################################################
81
82add_subdirectory(lib/ext)
83add_subdirectory(tools)
Minos Galanakisdff2eae2020-07-21 15:13:52 +010084add_subdirectory(docs)
Raef Coles9ec67e62020-07-10 09:40:35 +010085if(NS)
86 # Set to ${TFM_TEST_REPO_PATH}/app by default
87 add_subdirectory(${TFM_APP_PATH} ${CMAKE_CURRENT_BINARY_DIR}/app)
88endif()
89add_subdirectory(secure_fw)
90add_subdirectory(interface)
91if(BL2)
92 add_subdirectory(bl2)
93endif()
94add_subdirectory(platform)
95
96if(NS AND (TEST_S OR TEST_NS))
97 # Set to ${TFM_TEST_REPO_PATH}/test by default
98 add_subdirectory(${TFM_TEST_PATH} ${CMAKE_CURRENT_BINARY_DIR}/test)
99endif()
100
101include(cmake/install.cmake)
102
103if(CRYPTO_HW_ACCELERATOR)
104 add_subdirectory(platform/ext/accelerator)
105endif()