blob: 1301b1ff4d5e7254d91c8affd6b131668b285767 [file] [log] [blame]
Julian Hall4061ed62020-11-23 18:24:06 +01001#-------------------------------------------------------------------------------
Gyorgy Szing8a1e7f42023-07-26 18:26:48 +02002# Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved.
Julian Hall4061ed62020-11-23 18:24:06 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
Balint Dobszay047aea82022-05-16 14:20:53 +02007cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
Gyorgy Szinga365a042021-12-02 01:48:27 +01008
9# Set default platform.
10set(TS_PLATFORM "arm/fvp/fvp_base_revc-2xaemv8a" CACHE STRING "Target platform location.")
Gyorgy Szing34aaf212022-10-20 07:26:23 +020011
12# Te crypto SP is big. Set default build type to MinSizWithDebInfo to avoid running ouf of
13# secure memory on low resource IoT platforms.
14if (NOT DEFINED CMAKE_BUILD_TYPE)
15 set(CMAKE_BUILD_TYPE "MinSizWithDebInfo" CACHE STRING "Build type.")
16endif()
17
Julian Hall64f1d872022-09-05 16:52:40 +010018include(../../../deployment.cmake REQUIRED)
Julian Hall4061ed62020-11-23 18:24:06 +010019
20#-------------------------------------------------------------------------------
21# The CMakeLists.txt for building the crypto deployment for opteesp
22#
23# Builds the Crypto service provider for running in an SEL0 secure partition
24# hosted by OPTEE in the role of SPM.
25#-------------------------------------------------------------------------------
26include(${TS_ROOT}/environments/opteesp/env.cmake)
27project(trusted-services LANGUAGES C ASM)
Imre Kisd0ed5c22021-12-15 17:05:47 +010028add_executable(crypto)
29target_include_directories(crypto PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
Balint Dobszayc9daea92022-06-15 15:17:11 +020030set(SP_UUID_CANON "d9df52d5-16a2-4bb2-9aa4-d26d3b84e8c0")
Imre Kiseeee9642021-12-17 13:59:46 +010031set(SP_HEAP_SIZE "490 * 1024" CACHE STRING "SP heap size in bytes")
Imre Kis2ccd8e82021-10-08 11:21:14 +020032set(TRACE_PREFIX "CRYPTO" CACHE STRING "Trace prefix")
Julian Hall4061ed62020-11-23 18:24:06 +010033
Julian Hall64f1d872022-09-05 16:52:40 +010034target_include_directories(crypto PRIVATE
35 ${CMAKE_CURRENT_LIST_DIR}
36)
37
julhal01ffa98d82021-01-20 13:51:58 +000038#-------------------------------------------------------------------------------
Julian Hall64f1d872022-09-05 16:52:40 +010039# Deployment specific components
julhal01ffa98d82021-01-20 13:51:58 +000040#
41#-------------------------------------------------------------------------------
Imre Kisd0ed5c22021-12-15 17:05:47 +010042add_components(TARGET "crypto"
Julian Hall4061ed62020-11-23 18:24:06 +010043 BASE_DIR ${TS_ROOT}
44 COMPONENTS
Julian Hall4061ed62020-11-23 18:24:06 +010045 "environments/opteesp"
46)
47
Julian Hall64f1d872022-09-05 16:52:40 +010048include(../../env/commonsp/crypto_sp.cmake REQUIRED)
49include(../../crypto.cmake REQUIRED)
50include(../../infra/baremetal-psa.cmake REQUIRED)
Julian Hall4061ed62020-11-23 18:24:06 +010051
julhal01ffa98d82021-01-20 13:51:58 +000052#-------------------------------------------------------------------------------
Gyorgy Szinga365a042021-12-02 01:48:27 +010053# Set target platform to provide drivers needed by the deployment
julhal01ffa98d82021-01-20 13:51:58 +000054#
55#-------------------------------------------------------------------------------
Imre Kisd0ed5c22021-12-15 17:05:47 +010056add_platform(TARGET "crypto")
Julian Hall4061ed62020-11-23 18:24:06 +010057
Julian Hall64f1d872022-09-05 16:52:40 +010058#-------------------------------------------------------------------------------
59# Deployment specific build options
60#-------------------------------------------------------------------------------
Imre Kisd0ed5c22021-12-15 17:05:47 +010061target_compile_definitions(crypto PRIVATE
Julian Hall4061ed62020-11-23 18:24:06 +010062 ARM64=1
63)
64
Julian Hall4061ed62020-11-23 18:24:06 +010065if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
Imre Kisd0ed5c22021-12-15 17:05:47 +010066 target_compile_options(crypto PRIVATE
Andrew Beggs97a00d42021-06-15 15:45:46 +000067 -std=c99
Julian Hall4061ed62020-11-23 18:24:06 +010068 )
69
Julian Hall4061ed62020-11-23 18:24:06 +010070endif()
71
Julian Hall64f1d872022-09-05 16:52:40 +010072#-------------------------------------------------------------------------------
73# Deployment specific install options
74#-------------------------------------------------------------------------------
Julian Hall4061ed62020-11-23 18:24:06 +010075if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
76 set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
77endif()
78#TODO: api headers
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010079
Imre Kisd0ed5c22021-12-15 17:05:47 +010080install(TARGETS crypto
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010081 PUBLIC_HEADER DESTINATION ${TS_ENV}/include
82 RUNTIME DESTINATION ${TS_ENV}/bin
Julian Hall4061ed62020-11-23 18:24:06 +010083 )
Julian Hall4061ed62020-11-23 18:24:06 +010084
Imre Kisd0ed5c22021-12-15 17:05:47 +010085get_property(_PROTO_FILES TARGET crypto PROPERTY PROTOBUF_FILES)
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010086install(FILES ${_PROTO_FILES} DESTINATION ${TS_ENV}/lib/protobuf)
Julian Hall4061ed62020-11-23 18:24:06 +010087
Imre Kisa74aaf92021-12-14 17:13:06 +010088include(${TS_ROOT}/tools/cmake/common/ExportSp.cmake)
89export_sp(
Balint Dobszayc9daea92022-06-15 15:17:11 +020090 SP_UUID_CANON ${SP_UUID_CANON}
Imre Kisa74aaf92021-12-14 17:13:06 +010091 SP_NAME "crypto"
92 MK_IN ${TS_ROOT}/environments/opteesp/sp.mk.in
93 DTS_IN ${CMAKE_CURRENT_LIST_DIR}/default_crypto.dts.in
94 JSON_IN ${TS_ROOT}/environments/opteesp/sp_pkg.json.in
95)