Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Dávid Házi | 3357119 | 2024-10-10 13:05:28 +0000 | [diff] [blame] | 2 | # Copyright (c) 2023-2024, Arm Limited. All rights reserved. |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +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 | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 8 | |
| 9 | if (NOT DEFINED CONFIG_SPE_PATH OR NOT EXISTS ${CONFIG_SPE_PATH}) |
| 10 | 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=") |
| 11 | endif() |
| 12 | |
David Hu | 7042a26 | 2023-10-14 23:47:29 +0800 | [diff] [blame] | 13 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../cmake) |
| 14 | list(APPEND CMAKE_MODULE_PATH ${CONFIG_SPE_PATH}/cmake) |
David Hu | 479ef00 | 2023-10-20 14:44:32 +0800 | [diff] [blame] | 15 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/utils) |
David Hu | 7042a26 | 2023-10-14 23:47:29 +0800 | [diff] [blame] | 16 | include(remote_library) |
| 17 | include(toolchain_selection) |
Jianliang Shen | e852511 | 2023-10-20 17:18:43 +0800 | [diff] [blame] | 18 | include(utils) |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 19 | |
David Hu | 1ffdcfe | 2023-10-13 14:52:40 +0800 | [diff] [blame] | 20 | # A platform sprecific MCPU and architecture flags for NS side |
| 21 | include(${CONFIG_SPE_PATH}/platform/cpuarch.cmake) |
David Hu | a1de7d6 | 2023-10-26 11:18:11 +0800 | [diff] [blame] | 22 | # Include common configs exported from TF-M |
| 23 | include(${CONFIG_SPE_PATH}/cmake/spe_config.cmake) |
Kevin Peng | 2161356 | 2023-09-04 14:39:28 +0800 | [diff] [blame] | 24 | # Platform abilities for example IRQ test support status |
| 25 | include(${CONFIG_SPE_PATH}/platform/config.cmake OPTIONAL) |
Jianliang Shen | e852511 | 2023-10-20 17:18:43 +0800 | [diff] [blame] | 26 | |
David Hu | ea7f7ac | 2023-11-07 19:17:21 +0800 | [diff] [blame] | 27 | # Check current tf-m-tests is compatible to TF-M under verfication |
| 28 | include(check_version) |
| 29 | |
Jianliang Shen | e852511 | 2023-10-20 17:18:43 +0800 | [diff] [blame] | 30 | include(${TFM_TOOLCHAIN_FILE}) |
| 31 | project(tfm_ns LANGUAGES C ASM) |
Jianliang Shen | e852511 | 2023-10-20 17:18:43 +0800 | [diff] [blame] | 32 | |
David Hu | a1de7d6 | 2023-10-26 11:18:11 +0800 | [diff] [blame] | 33 | # If config_ns_test.cmake is exported from TF-M build, it indicates regression tests are enabled. |
| 34 | # Otherwise, skip test configuration |
Kevin Peng | 10a6201 | 2023-11-01 15:18:54 +0800 | [diff] [blame] | 35 | include(${CONFIG_SPE_PATH}/config/config_ns_test.cmake OPTIONAL) |
David Hu | a1de7d6 | 2023-10-26 11:18:11 +0800 | [diff] [blame] | 36 | if(TFM_NS_REG_TEST) |
| 37 | # Include platform specific regression tests config |
| 38 | include(${CONFIG_SPE_PATH}/platform/tests/tfm_tests_config.cmake OPTIONAL) |
| 39 | if (TFM_PROFILE) |
| 40 | include(${CMAKE_CURRENT_LIST_DIR}/test/config/profile/${TFM_PROFILE}_test.cmake) |
| 41 | endif() |
| 42 | # Default test configurations |
| 43 | include(${CMAKE_CURRENT_LIST_DIR}/test/config/default_test_config.cmake) |
| 44 | # Config check in case additional test configs passed in via command line. |
| 45 | include(${CMAKE_CURRENT_LIST_DIR}/test/config/check_config.cmake) |
Kevin Peng | 4216aa0 | 2023-10-27 17:04:42 +0800 | [diff] [blame] | 46 | endif() |
Jianliang Shen | e852511 | 2023-10-20 17:18:43 +0800 | [diff] [blame] | 47 | # Include coprocessor check to make sure NS toolchain is compatiable |
| 48 | include(${CONFIG_SPE_PATH}/config/cp_check.cmake) |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 49 | |
| 50 | add_executable(tfm_ns) |
| 51 | |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 52 | add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../lib/ext ${CMAKE_BINARY_DIR}/lib/ext) |
Anton Komlev | c0ad604 | 2023-08-29 18:23:26 +0100 | [diff] [blame] | 53 | add_subdirectory(../app_broker ${CMAKE_BINARY_DIR}/app_broker) |
David Hu | 479ef00 | 2023-10-20 14:44:32 +0800 | [diff] [blame] | 54 | if(TFM_NS_REG_TEST) |
| 55 | add_subdirectory(test/ns_regression) |
| 56 | endif() |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 57 | |
| 58 | ############################# TFM NS main app ################################## |
| 59 | |
| 60 | target_sources(tfm_ns |
| 61 | PRIVATE |
| 62 | test_app.c |
Kevin Peng | 9dff986 | 2023-10-09 11:06:08 +0800 | [diff] [blame] | 63 | $<$<BOOL:${CONFIG_GNU_SYSCALL_STUB_ENABLED}>:../app_broker/syscalls_stub.c> |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 64 | ) |
| 65 | |
| 66 | target_link_libraries(tfm_ns |
| 67 | PRIVATE |
Jamie Fox | 6d4ee16 | 2023-11-27 17:27:37 +0000 | [diff] [blame] | 68 | os_wrapper |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 69 | tfm_test_broker |
David Hu | 479ef00 | 2023-10-20 14:44:32 +0800 | [diff] [blame] | 70 | $<$<BOOL:${TFM_NS_REG_TEST}>:tfm_ns_tests> |
| 71 | ) |
| 72 | |
| 73 | target_compile_definitions(tfm_ns |
| 74 | PUBLIC |
| 75 | $<$<BOOL:${TFM_NS_REG_TEST}>:TFM_NS_REG_TEST> |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 76 | ) |
| 77 | |
| 78 | set_target_properties(tfm_ns PROPERTIES |
| 79 | SUFFIX ".axf" |
| 80 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" |
| 81 | ) |
David Hu | 1c1b816 | 2023-10-14 22:31:01 +0800 | [diff] [blame] | 82 | |
| 83 | target_add_scatter_file(tfm_ns ${CONFIG_SPE_PATH}/platform/linker_scripts) |
| 84 | |
| 85 | target_link_options(tfm_ns |
| 86 | PRIVATE |
| 87 | $<$<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] | 88 | $<$<C_COMPILER_ID:ARMClang>:--map> |
David Hu | c758b1e | 2023-11-01 14:51:03 +0800 | [diff] [blame] | 89 | $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_ns.map> |
David Hu | 1c1b816 | 2023-10-14 22:31:01 +0800 | [diff] [blame] | 90 | ) |
David Hu | e90feae | 2023-10-14 15:17:44 +0800 | [diff] [blame] | 91 | |
| 92 | add_convert_to_bin_target(tfm_ns) |