Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Gergely Korcsák | db4cf19 | 2024-11-28 13:35:24 +0000 | [diff] [blame] | 2 | # Copyright (c) 2023-2024, Arm Limited. All rights reserved. |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
David Hu | 4c3c0ca | 2023-12-02 22:09:18 +0800 | [diff] [blame] | 7 | cmake_minimum_required(VERSION 3.21) |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 8 | |
Kevin Peng | 40d7d9a | 2023-10-10 14:48:58 +0800 | [diff] [blame] | 9 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../cmake) |
| 10 | include(utils) |
| 11 | |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 12 | # Force cross compilation and avoid compiler search and test |
| 13 | set(CMAKE_SYSTEM_NAME Generic) |
| 14 | set(CMAKE_C_COMPILER_FORCED TRUE) |
| 15 | set(CMAKE_CXX_COMPILER_FORCED TRUE) |
| 16 | |
Gergely Korcsák | db4cf19 | 2024-11-28 13:35:24 +0000 | [diff] [blame] | 17 | collect_build_cmd_args(TFM_CMDLINE_CONFIGS) |
| 18 | |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 19 | project("TF-M SPE for PSA tests" LANGUAGES C) |
| 20 | |
| 21 | # use tf-m-tests/cmake folder |
| 22 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../../cmake) |
| 23 | include(remote_library) |
| 24 | |
| 25 | # User must specify which TEST_PSA_API suit name |
| 26 | if (NOT DEFINED TEST_PSA_API) |
| 27 | message(FATAL_ERROR "TEST_PSA_API is not defined. Please provide desired test suit name provide.") |
| 28 | endif() |
| 29 | |
| 30 | if (NOT DEFINED CONFIG_TFM_SOURCE_PATH OR NOT EXISTS ${CONFIG_TFM_SOURCE_PATH}) |
Kevin Peng | e7eec7c | 2023-10-27 15:10:12 +0800 | [diff] [blame] | 31 | 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 Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 32 | endif() |
| 33 | |
| 34 | if (NOT DEFINED PSA_ARCH_TESTS_PATH OR NOT EXISTS ${PSA_ARCH_TESTS_PATH}) |
Kevin Peng | 8a0ba23 | 2023-10-08 14:31:49 +0800 | [diff] [blame] | 35 | add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../fetch_repo ${CMAKE_BINARY_DIR}/fetch_repo) |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 36 | endif() |
| 37 | |
Kevin Peng | 40d7d9a | 2023-10-10 14:48:58 +0800 | [diff] [blame] | 38 | if ("${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") |
| 44 | endif() |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 45 | |
| 46 | #------------------------------------------------------------------------------ |
| 47 | |
| 48 | # tfm_s_test is IMPORTED to inform CMake that it has no source files. |
| 49 | add_executable(tfm_test_spe IMPORTED) |
| 50 | |
| 51 | include(ExternalProject) |
David Hu | 0a7d188 | 2023-11-13 16:20:11 +0800 | [diff] [blame] | 52 | |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 53 | ExternalProject_Add(TF-M |
| 54 | SOURCE_DIR ${CONFIG_TFM_SOURCE_PATH} |
| 55 | BINARY_DIR build-spe |
| 56 | INSTALL_DIR api_ns |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 57 | CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 58 | CMAKE_ARGS -DPSA_ARCH_TESTS_PATH=${PSA_ARCH_TESTS_PATH} |
Kevin Peng | 678a1fd | 2023-09-06 17:41:45 +0800 | [diff] [blame] | 59 | CMAKE_ARGS -DCONFIG_TFM_TEST_DIR=${CMAKE_SOURCE_DIR}/partitions |
David Hu | a1de7d6 | 2023-10-26 11:18:11 +0800 | [diff] [blame] | 60 | CMAKE_ARGS -DCONFIG_PSA_ARCH_TESTS_CONFIG_FILE=${CMAKE_CURRENT_LIST_DIR}/config/config_test_psa_api.cmake |
Kevin Peng | 40d7d9a | 2023-10-10 14:48:58 +0800 | [diff] [blame] | 61 | CMAKE_CACHE_DEFAULT_ARGS ${TFM_CMDLINE_CONFIGS} |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 62 | PREFIX "temp" |
David Hu | 0a7d188 | 2023-11-13 16:20:11 +0800 | [diff] [blame] | 63 | BUILD_ALWAYS ON |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 64 | ) |
| 65 | |
| 66 | add_dependencies(tfm_test_spe TF-M) |
| 67 | |
Antonio de Angelis | 7242999 | 2024-03-11 11:38:58 +0000 | [diff] [blame] | 68 | # Skip "up-to-date" prints to avoid flooding the build output. Just print "installing" |
| 69 | set(CMAKE_INSTALL_MESSAGE LAZY) |
| 70 | |
Anton Komlev | 4d4cc68 | 2023-09-05 16:33:53 +0100 | [diff] [blame] | 71 | install(DIRECTORY ${CMAKE_BINARY_DIR}/build-spe/bin DESTINATION ${CMAKE_BINARY_DIR}) |