blob: 40882c2d936346afb52a5600d715c97b9336d1fb [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 Colesa31a4b62020-11-10 09:49:17 +000057############################ Config Check ######################################
58
59include(${CMAKE_SOURCE_DIR}/config/check_config.cmake)
60
61if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/check_config.cmake)
62 include(platform/ext/target/${TFM_PLATFORM}/check_config.cmake)
63endif()
64
Raef Coles9ec67e62020-07-10 09:40:35 +010065################################################################################
66
67add_subdirectory(lib/ext)
68add_subdirectory(tools)
Minos Galanakisdff2eae2020-07-21 15:13:52 +010069add_subdirectory(docs)
Raef Coles9ec67e62020-07-10 09:40:35 +010070if(NS)
71 # Set to ${TFM_TEST_REPO_PATH}/app by default
72 add_subdirectory(${TFM_APP_PATH} ${CMAKE_CURRENT_BINARY_DIR}/app)
Kevin Pengca4846e2020-10-20 17:50:20 +080073 add_subdirectory(${TFM_NS_LOG_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ns_log)
Raef Coles9ec67e62020-07-10 09:40:35 +010074endif()
75add_subdirectory(secure_fw)
76add_subdirectory(interface)
77if(BL2)
78 add_subdirectory(bl2)
79endif()
80add_subdirectory(platform)
81
82if(NS AND (TEST_S OR TEST_NS))
83 # Set to ${TFM_TEST_REPO_PATH}/test by default
84 add_subdirectory(${TFM_TEST_PATH} ${CMAKE_CURRENT_BINARY_DIR}/test)
85endif()
86
87include(cmake/install.cmake)
88
89if(CRYPTO_HW_ACCELERATOR)
90 add_subdirectory(platform/ext/accelerator)
91endif()