blob: 42e779c575424310392e26f7c5ba50f958b78b42 [file] [log] [blame]
Anton Komlev4d4cc682023-09-05 16:33:53 +01001#-------------------------------------------------------------------------------
2# Copyright (c) 2023, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7cmake_minimum_required(VERSION 3.15)
8
David Hub4c9f9f2023-10-14 15:38:03 +08009# 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.
14if(POLICY CMP0123)
15 cmake_policy(SET CMP0123 NEW)
16endif()
17
Anton Komlev4d4cc682023-09-05 16:33:53 +010018#--- SPE artifacts -------------------------------------------------------------
19
20if (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=")
22endif()
23
24list(APPEND CMAKE_MODULE_PATH ${CONFIG_SPE_PATH}/cmake)
David Hu1ffdcfe2023-10-13 14:52:40 +080025
26# A platform sprecific MCPU and architecture flags for NS side
27include(${CONFIG_SPE_PATH}/platform/cpuarch.cmake)
28
Anton Komlev4d4cc682023-09-05 16:33:53 +010029include(spe_config)
30include(${CONFIG_SPE_PATH}/platform/config.cmake)
31
32set(CPU_ARCH ${PSA_API_TEST_CPU_ARCH})
33set(SUITE ${TEST_PSA_API})
34
35if (NOT "${TEST_PSA_API}" STREQUAL "IPC")
36 set(TARGET tgt_dev_apis_tfm_${PSA_API_TEST_TARGET})
37else()
38 set(TARGET tgt_ff_tfm_${PSA_API_TEST_TARGET})
39endif()
40
41#--- NSPE side project ---------------------------------------------------------
42
David Hue90feae2023-10-14 15:17:44 +080043if (NOT DEFINED TFM_TOOLCHAIN_FILE)
44 set(TFM_TOOLCHAIN_FILE ${CONFIG_SPE_PATH}/cmake/toolchain_ns_GNUARM.cmake)
Anton Komlev4d4cc682023-09-05 16:33:53 +010045endif()
46
47list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../cmake)
48
David Hue90feae2023-10-14 15:17:44 +080049include(${TFM_TOOLCHAIN_FILE})
Anton Komlev4d4cc682023-09-05 16:33:53 +010050project("TF-M PSA Arch tests" LANGUAGES C)
David Hue90feae2023-10-14 15:17:44 +080051tfm_toolchain_reload_compiler()
Anton Komlev4d4cc682023-09-05 16:33:53 +010052
53add_executable(tfm_ns)
54
55add_subdirectory(../app_broker ${CMAKE_BINARY_DIR}/app_broker)
56
57list(APPEND PSA_INCLUDE_PATHS ${CONFIG_SPE_PATH}/interface/include)
58
59if(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 )
64endif()
65
66set(PLATFORM_PSA_ISOLATION_LEVEL ${TFM_ISOLATION_LEVEL})
67
68add_subdirectory(${PSA_ARCH_TESTS_PATH}/api-tests ${CMAKE_BINARY_DIR}/api-tests)
69
70############################# TFM NS main app ##################################
71
72target_sources(tfm_ns
73 PRIVATE
74 test_app.c
75)
76
77target_link_libraries(tfm_ns
78 PRIVATE
79 tfm_test_broker
80 val_nspe
81 pal_nspe
82 test_combine
83)
84
85set_target_properties(tfm_ns PROPERTIES
86 SUFFIX ".axf"
87 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
88)
89
David Hu1c1b8162023-10-14 22:31:01 +080090target_add_scatter_file(tfm_ns ${CONFIG_SPE_PATH}/platform/linker_scripts)
91
92target_link_options(tfm_ns
93 PRIVATE
94 $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_ns.map>
David Hub4c9f9f2023-10-14 15:38:03 +080095 $<$<C_COMPILER_ID:ARMClang>:--map>
David Hu1c1b8162023-10-14 22:31:01 +080096)
David Hue90feae2023-10-14 15:17:44 +080097
98add_convert_to_bin_target(tfm_ns)