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) |
| 8 | include(../../deployment.cmake REQUIRED) |
| 9 | |
| 10 | #------------------------------------------------------------------------------- |
| 11 | # The CMakeLists.txt for building the env-test deployment for opteesp |
| 12 | # |
| 13 | # Builds the test_runner service provider for running in an SEL0 secure partition |
| 14 | # hosted by OPTEE in the role of SPM. Environment tests are added and CppUnit |
| 15 | # test cases. |
| 16 | #------------------------------------------------------------------------------- |
| 17 | include(${TS_ROOT}/environments/opteesp/env.cmake) |
julhal01 | 37e1aea | 2021-02-09 15:22:20 +0000 | [diff] [blame] | 18 | project(trusted-services LANGUAGES C ASM) |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame^] | 19 | add_executable(env-test) |
| 20 | target_include_directories(env-test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 21 | set(SP_UUID "33c75baf-ac6a-4fe4-8ac7-e9909bee2d17") |
| 22 | |
| 23 | |
| 24 | # Include SP DEV KIT interface |
| 25 | set(SP_DEV_KIT_INC_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 26 | list(APPEND CMAKE_MODULE_PATH "${TS_ROOT}/external/Spdevkit") |
| 27 | find_package(Spdevkit REQUIRED) |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame^] | 28 | sp_dev_kit_configure_linking(TARGET env-test DEFINES ARM64=1) |
| 29 | target_link_libraries(env-test PRIVATE ${SP_DEV_KIT_LIBRARIES}) |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 30 | |
| 31 | #------------------------------------------------------------------------------- |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame^] | 32 | # Components that are env-test specific to deployment in the opteesp |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 33 | # environment. |
| 34 | #------------------------------------------------------------------------------- |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame^] | 35 | add_components(TARGET "env-test" |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 36 | BASE_DIR ${TS_ROOT} |
| 37 | COMPONENTS |
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 | #------------------------------------------------------------------------------- |
| 50 | include(../env_test.cmake REQUIRED) |
| 51 | |
| 52 | #------------------------------------------------------------------------------- |
| 53 | # Deployment specific source files |
| 54 | #------------------------------------------------------------------------------- |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame^] | 55 | target_sources(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 56 | env_test.c |
julhal01 | 37e1aea | 2021-02-09 15:22:20 +0000 | [diff] [blame] | 57 | env_test_tests.c |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 58 | ) |
| 59 | |
| 60 | #------------------------------------------------------------------------------- |
| 61 | # Use the selected platform to provide drivers needed by the deployment |
| 62 | # |
| 63 | #------------------------------------------------------------------------------- |
| 64 | # temporarily force platform - remove when external builder updated |
| 65 | set(TS_PLATFORM "arm/fvp/fvp_base_revc-2xaemv8a" CACHE STRING "Overridden" FORCE) |
| 66 | |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame^] | 67 | add_platform(TARGET "env-test") |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 68 | |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 69 | if(CMAKE_CROSSCOMPILING) |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame^] | 70 | target_link_libraries(env-test PRIVATE stdc++ gcc m) |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 71 | endif() |
| 72 | |
| 73 | ################################################################# |
| 74 | |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame^] | 75 | target_compile_definitions(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 76 | ARM64=1 |
| 77 | ) |
| 78 | |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame^] | 79 | target_include_directories(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 80 | ${TS_ROOT} |
| 81 | ${TS_ROOT}/components |
| 82 | ${TS_ROOT}/deployments/env-test/opteesp |
| 83 | ) |
| 84 | |
| 85 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame^] | 86 | target_compile_options(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 87 | -fdiagnostics-show-option |
| 88 | -fpic |
| 89 | -gdwarf-2 |
| 90 | -mstrict-align |
| 91 | -O0 |
| 92 | $<$<COMPILE_LANGUAGE:C>:-std=gnu99> |
| 93 | $<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit> |
| 94 | ) |
| 95 | |
| 96 | # Options for GCC that control linking |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame^] | 97 | target_link_options(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 98 | -e __sp_entry |
| 99 | -fno-lto |
| 100 | -nostdlib |
| 101 | -pie |
| 102 | -zmax-page-size=4096 |
| 103 | ) |
| 104 | # Options directly for LD, these are not understood by GCC |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame^] | 105 | target_link_options(env-test PRIVATE |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 106 | -Wl,--as-needed |
| 107 | -Wl,--sort-section=alignment |
| 108 | # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list |
| 109 | ) |
| 110 | endif() |
| 111 | |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame^] | 112 | 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] | 113 | |
| 114 | ######################################## install |
| 115 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 116 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 117 | endif() |
| 118 | #TODO: api headers |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame^] | 119 | |
| 120 | install(TARGETS env-test |
| 121 | PUBLIC_HEADER DESTINATION ${TS_ENV}/include |
| 122 | RUNTIME DESTINATION ${TS_ENV}/bin |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 123 | ) |
Julian Hall | 7048d30 | 2021-06-03 16:07:28 +0100 | [diff] [blame^] | 124 | install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin) |
| 125 | |
| 126 | get_property(_PROTO_FILES TARGET env-test PROPERTY PROTOBUF_FILES) |
| 127 | install(FILES ${_PROTO_FILES} DESTINATION ${TS_ENV}/lib/protobuf) |
| 128 | |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 129 | |
| 130 | set(EXPORT_SP_NAME "env-test") |
| 131 | set(EXPORT_SP_UUID ${SP_UUID}) |
| 132 | include(${TS_ROOT}/environments/opteesp/ExportSp.cmake) |