Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +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 | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 18 | if (NOT DEFINED CONFIG_SPE_PATH OR NOT EXISTS ${CONFIG_SPE_PATH}) |
| 19 | 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=") |
| 20 | endif() |
| 21 | |
David Hu | 7042a26 | 2023-10-14 23:47:29 +0800 | [diff] [blame] | 22 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../cmake) |
| 23 | list(APPEND CMAKE_MODULE_PATH ${CONFIG_SPE_PATH}/cmake) |
David Hu | 479ef00 | 2023-10-20 14:44:32 +0800 | [diff] [blame] | 24 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/utils) |
David Hu | 7042a26 | 2023-10-14 23:47:29 +0800 | [diff] [blame] | 25 | include(remote_library) |
| 26 | include(toolchain_selection) |
Jianliang Shen | e852511 | 2023-10-20 17:18:43 +0800 | [diff] [blame] | 27 | include(utils) |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 28 | |
David Hu | 1ffdcfe | 2023-10-13 14:52:40 +0800 | [diff] [blame] | 29 | # A platform sprecific MCPU and architecture flags for NS side |
| 30 | include(${CONFIG_SPE_PATH}/platform/cpuarch.cmake) |
Kevin Peng | 2161356 | 2023-09-04 14:39:28 +0800 | [diff] [blame] | 31 | # Platform abilities for example IRQ test support status |
| 32 | include(${CONFIG_SPE_PATH}/platform/config.cmake OPTIONAL) |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 33 | |
David Hu | 479ef00 | 2023-10-20 14:44:32 +0800 | [diff] [blame] | 34 | # Include configs exported from TF-M |
| 35 | include(${CONFIG_SPE_PATH}/cmake/spe_config.cmake) |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 36 | |
Jianliang Shen | e852511 | 2023-10-20 17:18:43 +0800 | [diff] [blame] | 37 | # Include coprocessor configs |
| 38 | include(${CONFIG_SPE_PATH}/config/cp_config_default.cmake) |
| 39 | |
Kevin Peng | 2161356 | 2023-09-04 14:39:28 +0800 | [diff] [blame] | 40 | # Test suite configurations - set up by SPE build |
| 41 | include(${CONFIG_SPE_PATH}/config_ns_test.cmake) |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 42 | |
Jianliang Shen | e852511 | 2023-10-20 17:18:43 +0800 | [diff] [blame] | 43 | include(${TFM_TOOLCHAIN_FILE}) |
| 44 | project(tfm_ns LANGUAGES C ASM) |
| 45 | tfm_toolchain_reload_compiler() |
| 46 | |
Kevin Peng | 4216aa0 | 2023-10-27 17:04:42 +0800 | [diff] [blame^] | 47 | if (TFM_PROFILE) |
| 48 | include(${CMAKE_CURRENT_LIST_DIR}/test/config/profile/${TFM_PROFILE}_test.cmake) |
| 49 | endif() |
| 50 | |
David Hu | 479ef00 | 2023-10-20 14:44:32 +0800 | [diff] [blame] | 51 | # Default test configurations |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 52 | include(${CMAKE_CURRENT_LIST_DIR}/test/config/default_test_config.cmake) |
David Hu | 479ef00 | 2023-10-20 14:44:32 +0800 | [diff] [blame] | 53 | # Config check in case additional test configs passed in via command line. |
| 54 | include(${CMAKE_CURRENT_LIST_DIR}/test/config/check_config.cmake) |
Jianliang Shen | e852511 | 2023-10-20 17:18:43 +0800 | [diff] [blame] | 55 | # Include coprocessor check to make sure NS toolchain is compatiable |
| 56 | include(${CONFIG_SPE_PATH}/config/cp_check.cmake) |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 57 | |
| 58 | add_executable(tfm_ns) |
| 59 | |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 60 | 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] | 61 | add_subdirectory(../app_broker ${CMAKE_BINARY_DIR}/app_broker) |
David Hu | 479ef00 | 2023-10-20 14:44:32 +0800 | [diff] [blame] | 62 | if(TFM_NS_REG_TEST) |
| 63 | add_subdirectory(test/ns_regression) |
| 64 | endif() |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 65 | |
| 66 | ############################# TFM NS main app ################################## |
| 67 | |
| 68 | target_sources(tfm_ns |
| 69 | PRIVATE |
| 70 | test_app.c |
| 71 | ) |
| 72 | |
| 73 | target_link_libraries(tfm_ns |
| 74 | PRIVATE |
| 75 | tfm_test_broker |
David Hu | 479ef00 | 2023-10-20 14:44:32 +0800 | [diff] [blame] | 76 | $<$<BOOL:${TFM_NS_REG_TEST}>:tfm_ns_tests> |
| 77 | ) |
| 78 | |
| 79 | target_compile_definitions(tfm_ns |
| 80 | PUBLIC |
| 81 | $<$<BOOL:${TFM_NS_REG_TEST}>:TFM_NS_REG_TEST> |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 82 | ) |
| 83 | |
| 84 | set_target_properties(tfm_ns PROPERTIES |
| 85 | SUFFIX ".axf" |
| 86 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" |
| 87 | ) |
David Hu | 1c1b816 | 2023-10-14 22:31:01 +0800 | [diff] [blame] | 88 | |
| 89 | target_add_scatter_file(tfm_ns ${CONFIG_SPE_PATH}/platform/linker_scripts) |
| 90 | |
| 91 | target_link_options(tfm_ns |
| 92 | PRIVATE |
| 93 | $<$<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] | 94 | $<$<C_COMPILER_ID:ARMClang>:--map> |
David Hu | 1c1b816 | 2023-10-14 22:31:01 +0800 | [diff] [blame] | 95 | ) |
David Hu | e90feae | 2023-10-14 15:17:44 +0800 | [diff] [blame] | 96 | |
| 97 | add_convert_to_bin_target(tfm_ns) |