blob: 681ac89ff87b891a7add9e9e5b69d02cb40447fb [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
Raef Coles956bd5c2020-11-03 11:30:26 +000047if (NOT IS_ABSOLUTE ${TFM_TOOLCHAIN_FILE})
48 message(FATAL_ERROR "SETTING CMAKE_TOOLCHAIN_FILE no longer accepts relative paths. Please supply an absolute path or instead use TFM_TOOLCHAIN_FILE (which does accept relative paths)")
49endif()
50
Raef Coles69817322020-10-19 14:14:14 +010051include(${TFM_TOOLCHAIN_FILE})
52set(CMAKE_PROJECT_INCLUDE_BEFORE ${CMAKE_SOURCE_DIR}/cmake/disable_compiler_detection.cmake)
53
54project("Trusted Firmware M" VERSION ${TFM_VERSION} LANGUAGES C ASM)
55tfm_toolchain_reload_compiler()
56
Raef Coles9ec67e62020-07-10 09:40:35 +010057################################################################################
58
59add_subdirectory(lib/ext)
60add_subdirectory(tools)
Minos Galanakisdff2eae2020-07-21 15:13:52 +010061add_subdirectory(docs)
Raef Coles9ec67e62020-07-10 09:40:35 +010062if(NS)
63 # Set to ${TFM_TEST_REPO_PATH}/app by default
64 add_subdirectory(${TFM_APP_PATH} ${CMAKE_CURRENT_BINARY_DIR}/app)
Kevin Pengca4846e2020-10-20 17:50:20 +080065 add_subdirectory(${TFM_NS_LOG_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ns_log)
Raef Coles9ec67e62020-07-10 09:40:35 +010066endif()
67add_subdirectory(secure_fw)
68add_subdirectory(interface)
69if(BL2)
70 add_subdirectory(bl2)
71endif()
72add_subdirectory(platform)
73
74if(NS AND (TEST_S OR TEST_NS))
75 # Set to ${TFM_TEST_REPO_PATH}/test by default
76 add_subdirectory(${TFM_TEST_PATH} ${CMAKE_CURRENT_BINARY_DIR}/test)
77endif()
78
79include(cmake/install.cmake)
80
81if(CRYPTO_HW_ACCELERATOR)
82 add_subdirectory(platform/ext/accelerator)
83endif()