Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Gyorgy Szing | 8a1e7f4 | 2023-07-26 18:26:48 +0200 | [diff] [blame] | 2 | # Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved. |
Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
Balint Dobszay | 047aea8 | 2022-05-16 14:20:53 +0200 | [diff] [blame] | 7 | cmake_minimum_required(VERSION 3.18 FATAL_ERROR) |
Gyorgy Szing | a365a04 | 2021-12-02 01:48:27 +0100 | [diff] [blame] | 8 | |
| 9 | # Set default platform. |
| 10 | set(TS_PLATFORM "arm/fvp/fvp_base_revc-2xaemv8a" CACHE STRING "Target platform location.") |
Gyorgy Szing | 34aaf21 | 2022-10-20 07:26:23 +0200 | [diff] [blame] | 11 | |
| 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. |
| 14 | if (NOT DEFINED CMAKE_BUILD_TYPE) |
| 15 | set(CMAKE_BUILD_TYPE "MinSizWithDebInfo" CACHE STRING "Build type.") |
| 16 | endif() |
| 17 | |
Julian Hall | 64f1d87 | 2022-09-05 16:52:40 +0100 | [diff] [blame] | 18 | include(../../../deployment.cmake REQUIRED) |
Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 19 | |
| 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 | #------------------------------------------------------------------------------- |
| 26 | include(${TS_ROOT}/environments/opteesp/env.cmake) |
| 27 | project(trusted-services LANGUAGES C ASM) |
Imre Kis | d0ed5c2 | 2021-12-15 17:05:47 +0100 | [diff] [blame] | 28 | add_executable(crypto) |
| 29 | target_include_directories(crypto PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 30 | set(SP_UUID_CANON "d9df52d5-16a2-4bb2-9aa4-d26d3b84e8c0") |
Imre Kis | eeee964 | 2021-12-17 13:59:46 +0100 | [diff] [blame] | 31 | set(SP_HEAP_SIZE "490 * 1024" CACHE STRING "SP heap size in bytes") |
Imre Kis | 2ccd8e8 | 2021-10-08 11:21:14 +0200 | [diff] [blame] | 32 | set(TRACE_PREFIX "CRYPTO" CACHE STRING "Trace prefix") |
Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 33 | |
Julian Hall | 64f1d87 | 2022-09-05 16:52:40 +0100 | [diff] [blame] | 34 | target_include_directories(crypto PRIVATE |
| 35 | ${CMAKE_CURRENT_LIST_DIR} |
| 36 | ) |
| 37 | |
julhal01 | ffa98d8 | 2021-01-20 13:51:58 +0000 | [diff] [blame] | 38 | #------------------------------------------------------------------------------- |
Julian Hall | 64f1d87 | 2022-09-05 16:52:40 +0100 | [diff] [blame] | 39 | # Deployment specific components |
julhal01 | ffa98d8 | 2021-01-20 13:51:58 +0000 | [diff] [blame] | 40 | # |
| 41 | #------------------------------------------------------------------------------- |
Imre Kis | d0ed5c2 | 2021-12-15 17:05:47 +0100 | [diff] [blame] | 42 | add_components(TARGET "crypto" |
Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 43 | BASE_DIR ${TS_ROOT} |
| 44 | COMPONENTS |
Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 45 | "environments/opteesp" |
| 46 | ) |
| 47 | |
Julian Hall | 64f1d87 | 2022-09-05 16:52:40 +0100 | [diff] [blame] | 48 | include(../../env/commonsp/crypto_sp.cmake REQUIRED) |
| 49 | include(../../crypto.cmake REQUIRED) |
| 50 | include(../../infra/baremetal-psa.cmake REQUIRED) |
Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 51 | |
julhal01 | ffa98d8 | 2021-01-20 13:51:58 +0000 | [diff] [blame] | 52 | #------------------------------------------------------------------------------- |
Gyorgy Szing | a365a04 | 2021-12-02 01:48:27 +0100 | [diff] [blame] | 53 | # Set target platform to provide drivers needed by the deployment |
julhal01 | ffa98d8 | 2021-01-20 13:51:58 +0000 | [diff] [blame] | 54 | # |
| 55 | #------------------------------------------------------------------------------- |
Imre Kis | d0ed5c2 | 2021-12-15 17:05:47 +0100 | [diff] [blame] | 56 | add_platform(TARGET "crypto") |
Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 57 | |
Julian Hall | 64f1d87 | 2022-09-05 16:52:40 +0100 | [diff] [blame] | 58 | #------------------------------------------------------------------------------- |
| 59 | # Deployment specific build options |
| 60 | #------------------------------------------------------------------------------- |
Imre Kis | d0ed5c2 | 2021-12-15 17:05:47 +0100 | [diff] [blame] | 61 | target_compile_definitions(crypto PRIVATE |
Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 62 | ARM64=1 |
| 63 | ) |
| 64 | |
Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 65 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
Imre Kis | d0ed5c2 | 2021-12-15 17:05:47 +0100 | [diff] [blame] | 66 | target_compile_options(crypto PRIVATE |
Andrew Beggs | 97a00d4 | 2021-06-15 15:45:46 +0000 | [diff] [blame] | 67 | -std=c99 |
Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 68 | ) |
| 69 | |
Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 70 | endif() |
| 71 | |
Julian Hall | 64f1d87 | 2022-09-05 16:52:40 +0100 | [diff] [blame] | 72 | #------------------------------------------------------------------------------- |
| 73 | # Deployment specific install options |
| 74 | #------------------------------------------------------------------------------- |
Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 75 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 76 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 77 | endif() |
| 78 | #TODO: api headers |
Gyorgy Szing | c31afbf | 2021-02-12 01:51:55 +0100 | [diff] [blame] | 79 | |
Imre Kis | d0ed5c2 | 2021-12-15 17:05:47 +0100 | [diff] [blame] | 80 | install(TARGETS crypto |
Gyorgy Szing | c31afbf | 2021-02-12 01:51:55 +0100 | [diff] [blame] | 81 | PUBLIC_HEADER DESTINATION ${TS_ENV}/include |
| 82 | RUNTIME DESTINATION ${TS_ENV}/bin |
Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 83 | ) |
Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 84 | |
Imre Kis | d0ed5c2 | 2021-12-15 17:05:47 +0100 | [diff] [blame] | 85 | get_property(_PROTO_FILES TARGET crypto PROPERTY PROTOBUF_FILES) |
Gyorgy Szing | c31afbf | 2021-02-12 01:51:55 +0100 | [diff] [blame] | 86 | install(FILES ${_PROTO_FILES} DESTINATION ${TS_ENV}/lib/protobuf) |
Julian Hall | 4061ed6 | 2020-11-23 18:24:06 +0100 | [diff] [blame] | 87 | |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 88 | include(${TS_ROOT}/tools/cmake/common/ExportSp.cmake) |
| 89 | export_sp( |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 90 | SP_UUID_CANON ${SP_UUID_CANON} |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 91 | 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 | ) |