1#-------------------------------------------------------------------------------
2# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8#[===[.rst:
9  The base deployment CMake file
10  ------------------------------
11
12  Contains common CMake definitions that are used by concrete deployments.
13  This file should be included first by a concrete deployment's CMakeLists.txt.
14#]===]
15
16# Sets TS-ROOT which is used as the reference directory for everything contained within the project
17get_filename_component(TS_ROOT "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE CACHE PATH "Trusted Services root directory.")
18
19# Replicate TS_ROOT as environment variable to allow access from child CMake contexts
20set(ENV{TS_ROOT} "${TS_ROOT}")
21
22# Common utilities used by the build system
23include(${TS_ROOT}/tools/cmake/common/Utils.cmake REQUIRED)
24include(${TS_ROOT}/tools/cmake/common/AddComponents.cmake REQUIRED)
25include(${TS_ROOT}/tools/cmake/common/AddPlatform.cmake REQUIRED)
26include(${TS_ROOT}/tools/cmake/common/TsGetVersion.cmake REQUIRED)
27
28# Check build environment requirements are met
29ts_verify_build_env()
30
31# Project wide include directories
32set(TOP_LEVEL_INCLUDE_DIRS
33  "${TS_ROOT}"
34  "${TS_ROOT}/components"
35  )
36
37# Set platform provider root default to use if no commandline variable value has been specified.
38# The root path may be specified to allow an external project to provide platform definitions.
39if (DEFINED ENV{TS_PLATFORM_ROOT})
40  set(_default_platform_root ENV{TS_PLATFORM_ROOT})
41else()
42  set(_default_platform_root "${TS_ROOT}/platform/providers")
43endif()
44set(TS_PLATFORM_ROOT ${_default_platform_root} CACHE STRING "Platform provider path")
45
46# Set the default platform to use if no explict platform has been specified on the cmake commandline.
47if (DEFINED ENV{TS_PLATFORM})
48  set(_default_platform ENV{TS_PLATFORM})
49else()
50  set(_default_platform "ts/vanilla")
51endif()
52set(TS_PLATFORM ${_default_platform} CACHE STRING "Selected platform")
53
54# Custom property for defining platform feature dependencies based on components used in a deployment
55define_property(TARGET PROPERTY TS_PLATFORM_DRIVER_DEPENDENCIES
56  BRIEF_DOCS "List of platform driver interfaces used for a deployment."
57  FULL_DOCS "Used by the platform specific builder to specify a configuration for the built platform components."
58  )
59
60# Set default build type to Debug
61if (NOT CMAKE_BUILD_TYPE)
62  set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type.")
63endif()
64
65if (COVERAGE)
66	set(CMAKE_BUILD_TYPE "DebugCoverage" CACHE STRING "Build type" FORCE)
67endif()
68
69# List of supported build types. Needs to be in alignment with the toolchain file
70set(TS_SUPPORTED_BUILD_TYPES "DEBUG" "MINSIZEREL" "MINSIZWITHDEBINFO" "RELEASE" "RELWITHDEBINFO" "DEBUGCOVERAGE" CACHE
71  STRING "List of supported build types.")
72
73# Convert the build type string to upper case to help case insensitive comparison.
74string(TOUPPER "${CMAKE_BUILD_TYPE}" UC_CMAKE_BUILD_TYPE CACHE STRING "Easy to compare build type.")
75mark_as_advanced(UC_CMAKE_BUILD_TYPE)
76
77# Validate build type
78if (NOT "${UC_CMAKE_BUILD_TYPE}" IN_LIST TS_SUPPORTED_BUILD_TYPES)
79	message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\" specified in CMAKE_BUILD_TYPE.")
80endif()
81
82# Set postfix of libraries according the build type.
83set(CMAKE_DEBUGCOVERAGE_POSTFIX "c")
84set(CMAKE_DEBUG_POSTFIX "d")
85
86# Default protocol UUID used by TS SPs.
87set(TS_RPC_UUID_CANON "bdcd76d7-825e-4751-963b-86d4f84943ac" CACHE STRING "Trusted Services PRC (protocol) UUID.")
88