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) |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 19 | add_executable(env_test) |
| 20 | target_include_directories(env_test PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") |
| 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) |
| 28 | sp_dev_kit_configure_linking(TARGET env_test DEFINES ARM64=1) |
| 29 | target_link_libraries(env_test PRIVATE ${SP_DEV_KIT_LIBRARIES}) |
| 30 | |
| 31 | #------------------------------------------------------------------------------- |
| 32 | # Components that are env_testecific to deployment in the opteesp |
| 33 | # environment. |
| 34 | #------------------------------------------------------------------------------- |
| 35 | add_components(TARGET "env_test" |
| 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 |
| 47 | # env_test |
| 48 | # |
| 49 | #------------------------------------------------------------------------------- |
| 50 | include(../env_test.cmake REQUIRED) |
| 51 | |
| 52 | #------------------------------------------------------------------------------- |
| 53 | # Deployment specific source files |
| 54 | #------------------------------------------------------------------------------- |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 55 | target_sources(env_test PRIVATE |
| 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 | |
| 67 | add_platform(TARGET "env_test") |
| 68 | |
julhal01 | 3ec4c32 | 2021-02-05 17:30:49 +0000 | [diff] [blame] | 69 | if(CMAKE_CROSSCOMPILING) |
| 70 | target_link_libraries(env_test PRIVATE stdc++ gcc m) |
| 71 | endif() |
| 72 | |
| 73 | ################################################################# |
| 74 | |
| 75 | target_compile_definitions(env_test PRIVATE |
| 76 | ARM64=1 |
| 77 | ) |
| 78 | |
| 79 | target_include_directories(env_test PRIVATE |
| 80 | ${TS_ROOT} |
| 81 | ${TS_ROOT}/components |
| 82 | ${TS_ROOT}/deployments/env-test/opteesp |
| 83 | ) |
| 84 | |
| 85 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
| 86 | target_compile_options(env_test PRIVATE |
| 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 |
| 97 | target_link_options(env_test PRIVATE |
| 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 |
| 105 | target_link_options(env_test PRIVATE |
| 106 | -Wl,--as-needed |
| 107 | -Wl,--sort-section=alignment |
| 108 | # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list |
| 109 | ) |
| 110 | endif() |
| 111 | |
| 112 | compiler_generate_stripped_elf(TARGET env_test NAME "${SP_UUID}.stripped.elf" RES STRIPPED_ELF) |
| 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 |
| 119 | install(TARGETS env_test |
| 120 | PUBLIC_HEADER DESTINATION include |
| 121 | RUNTIME DESTINATION bin |
| 122 | ) |
| 123 | install(FILES ${STRIPPED_ELF} DESTINATION bin) |
| 124 | |
| 125 | set(EXPORT_SP_NAME "env-test") |
| 126 | set(EXPORT_SP_UUID ${SP_UUID}) |
| 127 | include(${TS_ROOT}/environments/opteesp/ExportSp.cmake) |