blob: 75986f7b0839c0112fee42c3327b567ef03c57ab [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
Tamas Ban69219202020-10-27 08:13:18 +000014# Some compiler flags depend on the CPU / platform config. This include should
15# be run before the toolchain file so the compiler can be configured properly.
16if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload.cmake)
17 Message(FATAL_ERROR "Unsupported TFM_PLATFORM ${TFM_PLATFORM}")
18else()
19 include(platform/ext/target/${TFM_PLATFORM}/preload.cmake)
20endif()
21
Raef Coles958aeef2020-10-08 12:12:58 +010022include(config/set_config.cmake)
Raef Coles9ec67e62020-07-10 09:40:35 +010023
Raef Coles69817322020-10-19 14:14:14 +010024if(NOT ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" AND
25 NOT ${CMAKE_GENERATOR} STREQUAL "Ninja")
26 Message(FATAL_ERROR "Unsupported generator ${CMAKE_GENERATOR}. Hint: Try -G\"Unix Makefiles\"")
27endif()
28
29# The default build type is release. If debug symbols are needed then
30# -DCMAKE_BUILD_TYPE=debug should be used (likewise with other build types)
31if (NOT CMAKE_BUILD_TYPE)
32 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type: [Debug, Release, RelWithDebInfo, MinSizeRel]" FORCE)
33endif()
34
35list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
36
37############################### Compiler configuration #########################
38
Raef Coles69817322020-10-19 14:14:14 +010039#Legacy compat option - load CMAKE_TOOLCHAIN_FILE as a TFM_TOOLCHAIN_FILE
40if (CMAKE_TOOLCHAIN_FILE)
41 message(DEPRECATION "SETTING CMAKE_TOOLCHAIN_FILE is deprecated. It has been replaced with TFM_TOOLCHAIN_FILE.")
42 message(DEPRECATION "INTERPRETING -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} as -DTFM_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
43 set(TFM_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
44 unset(CMAKE_TOOLCHAIN_FILE)
45endif()
46
47include(${TFM_TOOLCHAIN_FILE})
48set(CMAKE_PROJECT_INCLUDE_BEFORE ${CMAKE_SOURCE_DIR}/cmake/disable_compiler_detection.cmake)
49
50project("Trusted Firmware M" VERSION ${TFM_VERSION} LANGUAGES C ASM)
51tfm_toolchain_reload_compiler()
52
Raef Coles9ec67e62020-07-10 09:40:35 +010053################################################################################
54
55add_subdirectory(lib/ext)
56add_subdirectory(tools)
Minos Galanakisdff2eae2020-07-21 15:13:52 +010057add_subdirectory(docs)
Raef Coles9ec67e62020-07-10 09:40:35 +010058if(NS)
59 # Set to ${TFM_TEST_REPO_PATH}/app by default
60 add_subdirectory(${TFM_APP_PATH} ${CMAKE_CURRENT_BINARY_DIR}/app)
Kevin Pengca4846e2020-10-20 17:50:20 +080061 add_subdirectory(${TFM_NS_LOG_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ns_log)
Raef Coles9ec67e62020-07-10 09:40:35 +010062endif()
63add_subdirectory(secure_fw)
64add_subdirectory(interface)
65if(BL2)
66 add_subdirectory(bl2)
67endif()
68add_subdirectory(platform)
69
70if(NS AND (TEST_S OR TEST_NS))
71 # Set to ${TFM_TEST_REPO_PATH}/test by default
72 add_subdirectory(${TFM_TEST_PATH} ${CMAKE_CURRENT_BINARY_DIR}/test)
73endif()
74
75include(cmake/install.cmake)
76
77if(CRYPTO_HW_ACCELERATOR)
78 add_subdirectory(platform/ext/accelerator)
79endif()