Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2023, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | cmake_minimum_required(VERSION 3.15) |
| 8 | |
David Hu | b4c9f9f | 2023-10-14 15:38:03 +0800 | [diff] [blame^] | 9 | # CMake 3.21 and above requests projects to specify cpu/arch compile and link flags explicitly in |
| 10 | # Armclang. Link: https://cmake.org/cmake/help/latest/policy/CMP0123.html |
| 11 | # It is aligned with current Armclang toolchain implementation. |
| 12 | # Explictly set this policy to NEW behavior to eliminate long warnings. It shall be set in root |
| 13 | # CMakeLists.txt otherwise project() will throw out the warnings. |
| 14 | if(POLICY CMP0123) |
| 15 | cmake_policy(SET CMP0123 NEW) |
| 16 | endif() |
| 17 | |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 18 | #--- SPE artifacts ------------------------------------------------------------- |
| 19 | |
| 20 | if (NOT DEFINED CONFIG_SPE_PATH OR NOT EXISTS ${CONFIG_SPE_PATH}) |
| 21 | message(FATAL_ERROR "CONFIG_SPE_PATH = ${CONFIG_SPE_PATH} is not defined or incorrect. Please provide full path to TF-M build artifacts using -DCONFIG_SPE_PATH=") |
| 22 | endif() |
| 23 | |
| 24 | list(APPEND CMAKE_MODULE_PATH ${CONFIG_SPE_PATH}/cmake) |
David Hu | 1ffdcfe | 2023-10-13 14:52:40 +0800 | [diff] [blame] | 25 | |
| 26 | # A platform sprecific MCPU and architecture flags for NS side |
| 27 | include(${CONFIG_SPE_PATH}/platform/cpuarch.cmake) |
| 28 | |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 29 | include(spe_config) |
| 30 | include(${CONFIG_SPE_PATH}/platform/config.cmake) |
| 31 | |
| 32 | set(CPU_ARCH ${PSA_API_TEST_CPU_ARCH}) |
| 33 | set(SUITE ${TEST_PSA_API}) |
| 34 | |
| 35 | if (NOT "${TEST_PSA_API}" STREQUAL "IPC") |
| 36 | set(TARGET tgt_dev_apis_tfm_${PSA_API_TEST_TARGET}) |
| 37 | else() |
| 38 | set(TARGET tgt_ff_tfm_${PSA_API_TEST_TARGET}) |
| 39 | endif() |
| 40 | |
| 41 | #--- NSPE side project --------------------------------------------------------- |
| 42 | |
David Hu | e90feae | 2023-10-14 15:17:44 +0800 | [diff] [blame] | 43 | if (NOT DEFINED TFM_TOOLCHAIN_FILE) |
| 44 | set(TFM_TOOLCHAIN_FILE ${CONFIG_SPE_PATH}/cmake/toolchain_ns_GNUARM.cmake) |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 45 | endif() |
| 46 | |
| 47 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../cmake) |
| 48 | |
David Hu | e90feae | 2023-10-14 15:17:44 +0800 | [diff] [blame] | 49 | include(${TFM_TOOLCHAIN_FILE}) |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 50 | project("TF-M PSA Arch tests" LANGUAGES C) |
David Hu | e90feae | 2023-10-14 15:17:44 +0800 | [diff] [blame] | 51 | tfm_toolchain_reload_compiler() |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 52 | |
| 53 | add_executable(tfm_ns) |
| 54 | |
| 55 | add_subdirectory(../app_broker ${CMAKE_BINARY_DIR}/app_broker) |
| 56 | |
| 57 | list(APPEND PSA_INCLUDE_PATHS ${CONFIG_SPE_PATH}/interface/include) |
| 58 | |
| 59 | if(NOT PSA_INCLUDE_PATHS) |
| 60 | set(PSA_INCLUDE_PATHS ${INTERFACE_INC_DIR}/ |
| 61 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/ |
| 62 | ${CMAKE_BINARY_DIR}/generated/interface/include |
| 63 | ) |
| 64 | endif() |
| 65 | |
| 66 | set(PLATFORM_PSA_ISOLATION_LEVEL ${TFM_ISOLATION_LEVEL}) |
| 67 | |
| 68 | add_subdirectory(${PSA_ARCH_TESTS_PATH}/api-tests ${CMAKE_BINARY_DIR}/api-tests) |
| 69 | |
| 70 | ############################# TFM NS main app ################################## |
| 71 | |
| 72 | target_sources(tfm_ns |
| 73 | PRIVATE |
| 74 | test_app.c |
| 75 | ) |
| 76 | |
| 77 | target_link_libraries(tfm_ns |
| 78 | PRIVATE |
| 79 | tfm_test_broker |
| 80 | val_nspe |
| 81 | pal_nspe |
| 82 | test_combine |
| 83 | ) |
| 84 | |
| 85 | set_target_properties(tfm_ns PROPERTIES |
| 86 | SUFFIX ".axf" |
| 87 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" |
| 88 | ) |
| 89 | |
David Hu | 1c1b816 | 2023-10-14 22:31:01 +0800 | [diff] [blame] | 90 | target_add_scatter_file(tfm_ns ${CONFIG_SPE_PATH}/platform/linker_scripts) |
| 91 | |
| 92 | target_link_options(tfm_ns |
| 93 | PRIVATE |
| 94 | $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_ns.map> |
David Hu | b4c9f9f | 2023-10-14 15:38:03 +0800 | [diff] [blame^] | 95 | $<$<C_COMPILER_ID:ARMClang>:--map> |
David Hu | 1c1b816 | 2023-10-14 22:31:01 +0800 | [diff] [blame] | 96 | ) |
David Hu | e90feae | 2023-10-14 15:17:44 +0800 | [diff] [blame] | 97 | |
| 98 | add_convert_to_bin_target(tfm_ns) |