julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Imre Kis | eeee964 | 2021-12-17 13:59:46 +0100 | [diff] [blame] | 2 | # Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved. |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [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.") |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 11 | include(../../deployment.cmake REQUIRED) |
| 12 | |
| 13 | #------------------------------------------------------------------------------- |
| 14 | # The CMakeLists.txt for building the env-test deployment for opteesp |
| 15 | # |
| 16 | # Builds the test_runner service provider for running in an SEL0 secure partition |
| 17 | # hosted by OPTEE in the role of SPM. Environment tests are added and CppUnit |
| 18 | # test cases. |
| 19 | #------------------------------------------------------------------------------- |
| 20 | include(${TS_ROOT}/environments/opteesp/env.cmake) |
julhal01 | 37e1aea | 2021-02-09 15:22:20 +0000 | [diff] [blame] | 21 | project(trusted-services LANGUAGES C ASM) |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 22 | add_executable(env-test) |
| 23 | target_include_directories(env-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 24 | set(SP_UUID_CANON "33c75baf-ac6a-4fe4-8ac7-e9909bee2d17") |
Imre Kis | eeee964 | 2021-12-17 13:59:46 +0100 | [diff] [blame] | 25 | set(SP_HEAP_SIZE "32 * 1024" CACHE STRING "SP heap size in bytes") |
Imre Kis | 2ccd8e8 | 2021-10-08 11:21:14 +0200 | [diff] [blame] | 26 | set(TRACE_PREFIX "ENVTEST" CACHE STRING "Trace prefix") |
Jelle Sels | f1cb052 | 2022-06-30 11:31:31 +0200 | [diff] [blame^] | 27 | include(${TS_ROOT}/tools/cmake/common/TargetCompileDefinitions.cmake) |
| 28 | set_target_uuids( |
| 29 | SP_UUID ${SP_UUID_CANON} |
| 30 | SP_NAME "env-test" |
| 31 | ) |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 32 | |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 33 | #------------------------------------------------------------------------------- |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 34 | # Components that are env-test specific to deployment in the opteesp |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 35 | # environment. |
| 36 | #------------------------------------------------------------------------------- |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 37 | add_components(TARGET "env-test" |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 38 | BASE_DIR ${TS_ROOT} |
| 39 | COMPONENTS |
Balint Dobszay | 286ff75 | 2022-03-04 15:57:19 +0100 | [diff] [blame] | 40 | "components/common/fdt" |
Imre Kis | 2ccd8e8 | 2021-10-08 11:21:14 +0200 | [diff] [blame] | 41 | "components/common/trace" |
| 42 | "components/common/utils" |
julhal01 | 37e1aea | 2021-02-09 15:22:20 +0000 | [diff] [blame] | 43 | "components/config/loader/sp" |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 44 | "components/messaging/ffa/libsp" |
| 45 | "components/rpc/ffarpc/endpoint" |
julhal01 | 37e1aea | 2021-02-09 15:22:20 +0000 | [diff] [blame] | 46 | "components/config/test/sp" |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 47 | "environments/opteesp" |
| 48 | ) |
| 49 | |
julhal01 | 37e1aea | 2021-02-09 15:22:20 +0000 | [diff] [blame] | 50 | #------------------------------------------------------------------------------- |
| 51 | # Extend with components that are common across all deployments of |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 52 | # env-test |
julhal01 | 37e1aea | 2021-02-09 15:22:20 +0000 | [diff] [blame] | 53 | # |
| 54 | #------------------------------------------------------------------------------- |
Imre Kis | d0ed5c2 | 2021-12-15 17:05:47 +0100 | [diff] [blame] | 55 | include(../env-test.cmake REQUIRED) |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 56 | |
| 57 | #------------------------------------------------------------------------------- |
Gyorgy Szing | a365a04 | 2021-12-02 01:48:27 +0100 | [diff] [blame] | 58 | # Set target platform to provide drivers needed by the deployment |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 59 | # |
| 60 | #------------------------------------------------------------------------------- |
Gyorgy Szing | fceef6a | 2021-12-11 16:20:59 +0000 | [diff] [blame] | 61 | add_platform(TARGET env-test) |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 62 | |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 63 | if(CMAKE_CROSSCOMPILING) |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 64 | target_link_libraries(env-test PRIVATE stdc++ gcc m) |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 65 | endif() |
| 66 | |
| 67 | ################################################################# |
| 68 | |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 69 | target_compile_definitions(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 70 | ARM64=1 |
| 71 | ) |
| 72 | |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 73 | target_include_directories(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 74 | ${TS_ROOT}/deployments/env-test/opteesp |
| 75 | ) |
| 76 | |
| 77 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 78 | target_compile_options(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 79 | -fdiagnostics-show-option |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 80 | -gdwarf-2 |
| 81 | -mstrict-align |
| 82 | -O0 |
Andrew Beggs | 97a00d4 | 2021-06-15 15:45:46 +0000 | [diff] [blame] | 83 | $<$<COMPILE_LANGUAGE:C>:-std=c99> |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 84 | $<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit> |
| 85 | ) |
| 86 | |
| 87 | # Options for GCC that control linking |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 88 | target_link_options(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 89 | -zmax-page-size=4096 |
| 90 | ) |
| 91 | # Options directly for LD, these are not understood by GCC |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 92 | target_link_options(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 93 | -Wl,--as-needed |
| 94 | -Wl,--sort-section=alignment |
| 95 | # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list |
| 96 | ) |
| 97 | endif() |
| 98 | |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 99 | compiler_generate_stripped_elf(TARGET env-test NAME "${SP_UUID_CANON}.stripped.elf" RES STRIPPED_ELF) |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 100 | |
| 101 | ######################################## install |
| 102 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 103 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 104 | endif() |
| 105 | #TODO: api headers |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 106 | |
| 107 | install(TARGETS env-test |
| 108 | PUBLIC_HEADER DESTINATION ${TS_ENV}/include |
| 109 | RUNTIME DESTINATION ${TS_ENV}/bin |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 110 | ) |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 111 | install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin) |
| 112 | |
| 113 | get_property(_PROTO_FILES TARGET env-test PROPERTY PROTOBUF_FILES) |
| 114 | install(FILES ${_PROTO_FILES} DESTINATION ${TS_ENV}/lib/protobuf) |
| 115 | |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 116 | include(${TS_ROOT}/tools/cmake/common/ExportSp.cmake) |
| 117 | export_sp( |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 118 | SP_UUID_CANON ${SP_UUID_CANON} |
| 119 | SP_UUID_LE ${SP_UUID_LE} |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 120 | SP_NAME "env-test" |
| 121 | MK_IN ${TS_ROOT}/environments/opteesp/sp.mk.in |
| 122 | DTS_IN ${CMAKE_CURRENT_LIST_DIR}/default_env-test.dts.in |
| 123 | JSON_IN ${TS_ROOT}/environments/opteesp/sp_pkg.json.in |
| 124 | ) |