blob: 64f7d00cce0a0cede7a9274904d832cf585dd297 [file] [log] [blame]
Anton Komlev4d4cc682023-09-05 16:33:53 +01001#-------------------------------------------------------------------------------
Gergely Korcsákdb4cf192024-11-28 13:35:24 +00002# Copyright (c) 2023-2024, Arm Limited. All rights reserved.
Anton Komlev4d4cc682023-09-05 16:33:53 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
David Hu4c3c0ca2023-12-02 22:09:18 +08007cmake_minimum_required(VERSION 3.21)
Anton Komlev4d4cc682023-09-05 16:33:53 +01008
Kevin Peng40d7d9a2023-10-10 14:48:58 +08009list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../cmake)
10include(utils)
11
Anton Komlev4d4cc682023-09-05 16:33:53 +010012# Force cross compilation and avoid compiler search and test
13set(CMAKE_SYSTEM_NAME Generic)
14set(CMAKE_C_COMPILER_FORCED TRUE)
15set(CMAKE_CXX_COMPILER_FORCED TRUE)
16
Gergely Korcsákdb4cf192024-11-28 13:35:24 +000017collect_build_cmd_args(TFM_CMDLINE_CONFIGS)
18
Anton Komlev4d4cc682023-09-05 16:33:53 +010019project("TF-M SPE for PSA tests" LANGUAGES C)
20
21# use tf-m-tests/cmake folder
22list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../../cmake)
23include(remote_library)
24
25# User must specify which TEST_PSA_API suit name
26if (NOT DEFINED TEST_PSA_API)
27 message(FATAL_ERROR "TEST_PSA_API is not defined. Please provide desired test suit name provide.")
28endif()
29
30if (NOT DEFINED CONFIG_TFM_SOURCE_PATH OR NOT EXISTS ${CONFIG_TFM_SOURCE_PATH})
Kevin Penge7eec7c2023-10-27 15:10:12 +080031 message(FATAL_ERROR "CONFIG_TFM_SOURCE_PATH = ${CONFIG_TFM_SOURCE_PATH} is not defined or incorrect. Please provide full path to TF-M sources.")
Anton Komlev4d4cc682023-09-05 16:33:53 +010032endif()
33
34if (NOT DEFINED PSA_ARCH_TESTS_PATH OR NOT EXISTS ${PSA_ARCH_TESTS_PATH})
Kevin Peng8a0ba232023-10-08 14:31:49 +080035 add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../fetch_repo ${CMAKE_BINARY_DIR}/fetch_repo)
Anton Komlev4d4cc682023-09-05 16:33:53 +010036endif()
37
Kevin Peng40d7d9a2023-10-10 14:48:58 +080038if ("${TEST_PSA_API}" STREQUAL "IPC")
39 # Workaround: amend IPC backend config to command-line options so that users (including CI)
40 # do not need to set backend for FF tests.
41 # This should be done in the config_test_psa_api.cmake but it is included by TF-M too late.
42 # So setting backend in it does not take effect.
43 set(TFM_CMDLINE_CONFIGS "${TFM_CMDLINE_CONFIGS};-DCONFIG_TFM_SPM_BACKEND:UNINITIALIZED=IPC")
44endif()
Anton Komlev4d4cc682023-09-05 16:33:53 +010045
46#------------------------------------------------------------------------------
47
48# tfm_s_test is IMPORTED to inform CMake that it has no source files.
49add_executable(tfm_test_spe IMPORTED)
50
51include(ExternalProject)
David Hu0a7d1882023-11-13 16:20:11 +080052
Anton Komlev4d4cc682023-09-05 16:33:53 +010053ExternalProject_Add(TF-M
54 SOURCE_DIR ${CONFIG_TFM_SOURCE_PATH}
55 BINARY_DIR build-spe
56 INSTALL_DIR api_ns
Anton Komlev4d4cc682023-09-05 16:33:53 +010057 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
Anton Komlev4d4cc682023-09-05 16:33:53 +010058 CMAKE_ARGS -DPSA_ARCH_TESTS_PATH=${PSA_ARCH_TESTS_PATH}
Kevin Peng678a1fd2023-09-06 17:41:45 +080059 CMAKE_ARGS -DCONFIG_TFM_TEST_DIR=${CMAKE_SOURCE_DIR}/partitions
David Hua1de7d62023-10-26 11:18:11 +080060 CMAKE_ARGS -DCONFIG_PSA_ARCH_TESTS_CONFIG_FILE=${CMAKE_CURRENT_LIST_DIR}/config/config_test_psa_api.cmake
Kevin Peng40d7d9a2023-10-10 14:48:58 +080061 CMAKE_CACHE_DEFAULT_ARGS ${TFM_CMDLINE_CONFIGS}
Anton Komlev4d4cc682023-09-05 16:33:53 +010062 PREFIX "temp"
David Hu0a7d1882023-11-13 16:20:11 +080063 BUILD_ALWAYS ON
Anton Komlev4d4cc682023-09-05 16:33:53 +010064)
65
66add_dependencies(tfm_test_spe TF-M)
67
Antonio de Angelis72429992024-03-11 11:38:58 +000068# Skip "up-to-date" prints to avoid flooding the build output. Just print "installing"
69set(CMAKE_INSTALL_MESSAGE LAZY)
70
Anton Komlev4d4cc682023-09-05 16:33:53 +010071install(DIRECTORY ${CMAKE_BINARY_DIR}/build-spe/bin DESTINATION ${CMAKE_BINARY_DIR})