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