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 | #------------------------------------------------------------------------------- |
| 7 | cmake_minimum_required(VERSION 3.16) |
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}") |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 24 | set(SP_UUID "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") |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 27 | |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 28 | #------------------------------------------------------------------------------- |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 29 | # Components that are env-test specific to deployment in the opteesp |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 30 | # environment. |
| 31 | #------------------------------------------------------------------------------- |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 32 | add_components(TARGET "env-test" |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 33 | BASE_DIR ${TS_ROOT} |
| 34 | COMPONENTS |
Balint Dobszay | 286ff75 | 2022-03-04 15:57:19 +0100 | [diff] [blame] | 35 | "components/common/fdt" |
Imre Kis | 2ccd8e8 | 2021-10-08 11:21:14 +0200 | [diff] [blame] | 36 | "components/common/trace" |
| 37 | "components/common/utils" |
julhal01 | 37e1aea | 2021-02-09 15:22:20 +0000 | [diff] [blame] | 38 | "components/config/loader/sp" |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 39 | "components/messaging/ffa/libsp" |
| 40 | "components/rpc/ffarpc/endpoint" |
julhal01 | 37e1aea | 2021-02-09 15:22:20 +0000 | [diff] [blame] | 41 | "components/config/test/sp" |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 42 | "environments/opteesp" |
| 43 | ) |
| 44 | |
julhal01 | 37e1aea | 2021-02-09 15:22:20 +0000 | [diff] [blame] | 45 | #------------------------------------------------------------------------------- |
| 46 | # Extend with components that are common across all deployments of |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 47 | # env-test |
julhal01 | 37e1aea | 2021-02-09 15:22:20 +0000 | [diff] [blame] | 48 | # |
| 49 | #------------------------------------------------------------------------------- |
Imre Kis | d0ed5c2 | 2021-12-15 17:05:47 +0100 | [diff] [blame] | 50 | include(../env-test.cmake REQUIRED) |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 51 | |
| 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 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 54 | # |
| 55 | #------------------------------------------------------------------------------- |
Gyorgy Szing | fceef6a | 2021-12-11 16:20:59 +0000 | [diff] [blame] | 56 | add_platform(TARGET env-test) |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 57 | |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 58 | if(CMAKE_CROSSCOMPILING) |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 59 | target_link_libraries(env-test PRIVATE stdc++ gcc m) |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 60 | endif() |
| 61 | |
| 62 | ################################################################# |
| 63 | |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 64 | target_compile_definitions(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 65 | ARM64=1 |
| 66 | ) |
| 67 | |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 68 | target_include_directories(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 69 | ${TS_ROOT}/deployments/env-test/opteesp |
| 70 | ) |
| 71 | |
| 72 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 73 | target_compile_options(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 74 | -fdiagnostics-show-option |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 75 | -gdwarf-2 |
| 76 | -mstrict-align |
| 77 | -O0 |
Andrew Beggs | 97a00d4 | 2021-06-15 15:45:46 +0000 | [diff] [blame] | 78 | $<$<COMPILE_LANGUAGE:C>:-std=c99> |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 79 | $<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit> |
| 80 | ) |
| 81 | |
| 82 | # Options for GCC that control linking |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 83 | target_link_options(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 84 | -zmax-page-size=4096 |
| 85 | ) |
| 86 | # Options directly for LD, these are not understood by GCC |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 87 | target_link_options(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 88 | -Wl,--as-needed |
| 89 | -Wl,--sort-section=alignment |
| 90 | # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list |
| 91 | ) |
| 92 | endif() |
| 93 | |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 94 | compiler_generate_stripped_elf(TARGET env-test NAME "${SP_UUID}.stripped.elf" RES STRIPPED_ELF) |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 95 | |
| 96 | ######################################## install |
| 97 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 98 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 99 | endif() |
| 100 | #TODO: api headers |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 101 | |
| 102 | install(TARGETS env-test |
| 103 | PUBLIC_HEADER DESTINATION ${TS_ENV}/include |
| 104 | RUNTIME DESTINATION ${TS_ENV}/bin |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 105 | ) |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame] | 106 | install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin) |
| 107 | |
| 108 | get_property(_PROTO_FILES TARGET env-test PROPERTY PROTOBUF_FILES) |
| 109 | install(FILES ${_PROTO_FILES} DESTINATION ${TS_ENV}/lib/protobuf) |
| 110 | |
Imre Kis | a74aaf9 | 2021-12-14 17:13:06 +0100 | [diff] [blame] | 111 | include(${TS_ROOT}/tools/cmake/common/ExportSp.cmake) |
| 112 | export_sp( |
| 113 | SP_UUID ${SP_UUID} |
| 114 | SP_NAME "env-test" |
| 115 | MK_IN ${TS_ROOT}/environments/opteesp/sp.mk.in |
| 116 | DTS_IN ${CMAKE_CURRENT_LIST_DIR}/default_env-test.dts.in |
| 117 | JSON_IN ${TS_ROOT}/environments/opteesp/sp_pkg.json.in |
| 118 | ) |