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 | e90feae | 2023-10-14 15:17:44 +0800 | [diff] [blame] | 22 | if (NOT DEFINED TFM_TOOLCHAIN_FILE) |
| 23 | set(TFM_TOOLCHAIN_FILE ${CONFIG_SPE_PATH}/cmake/toolchain_ns_GNUARM.cmake) |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 24 | endif() |
| 25 | |
David Hu | 1ffdcfe | 2023-10-13 14:52:40 +0800 | [diff] [blame] | 26 | # A platform sprecific MCPU and architecture flags for NS side |
| 27 | include(${CONFIG_SPE_PATH}/platform/cpuarch.cmake) |
Kevin Peng | 2161356 | 2023-09-04 14:39:28 +0800 | [diff] [blame] | 28 | # Platform abilities for example IRQ test support status |
| 29 | include(${CONFIG_SPE_PATH}/platform/config.cmake OPTIONAL) |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 30 | |
| 31 | set(TFM_NS_REG_TEST ON) |
| 32 | set(NS ON) |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 33 | |
Kevin Peng | 2161356 | 2023-09-04 14:39:28 +0800 | [diff] [blame] | 34 | # Test suite configurations - set up by SPE build |
| 35 | include(${CONFIG_SPE_PATH}/config_ns_test.cmake) |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 36 | |
Kevin Peng | 2161356 | 2023-09-04 14:39:28 +0800 | [diff] [blame] | 37 | # Test configurations |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 38 | include(${CMAKE_CURRENT_LIST_DIR}/test/config/default_test_config.cmake) |
| 39 | |
| 40 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../cmake) |
| 41 | list(APPEND CMAKE_MODULE_PATH ${CONFIG_SPE_PATH}/cmake) |
Kevin Peng | aa32cdf | 2023-09-11 10:38:22 +0800 | [diff] [blame] | 42 | include(remote_library) |
| 43 | |
| 44 | add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../lib/ext ${CMAKE_BINARY_DIR}/lib/ext) |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 45 | |
David Hu | e90feae | 2023-10-14 15:17:44 +0800 | [diff] [blame] | 46 | include(${TFM_TOOLCHAIN_FILE}) |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 47 | project(tfm_ns LANGUAGES C) |
David Hu | e90feae | 2023-10-14 15:17:44 +0800 | [diff] [blame] | 48 | tfm_toolchain_reload_compiler() |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 49 | |
| 50 | add_executable(tfm_ns) |
| 51 | |
Anton Komlev | c0ad604 | 2023-08-29 18:23:26 +0100 | [diff] [blame] | 52 | add_subdirectory(../app_broker ${CMAKE_BINARY_DIR}/app_broker) |
Anton Komlev | e4b96ad | 2023-09-05 17:09:28 +0100 | [diff] [blame] | 53 | add_subdirectory(test) |
Anton Komlev | 84283b0 | 2023-08-16 10:57:56 +0100 | [diff] [blame] | 54 | |
| 55 | ############################# TFM NS main app ################################## |
| 56 | |
| 57 | target_sources(tfm_ns |
| 58 | PRIVATE |
| 59 | test_app.c |
| 60 | ) |
| 61 | |
| 62 | target_link_libraries(tfm_ns |
| 63 | PRIVATE |
| 64 | tfm_test_broker |
| 65 | tfm_ns_tests |
| 66 | tfm_test_framework_common |
| 67 | ) |
| 68 | |
| 69 | set_target_properties(tfm_ns PROPERTIES |
| 70 | SUFFIX ".axf" |
| 71 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" |
| 72 | ) |
David Hu | 1c1b816 | 2023-10-14 22:31:01 +0800 | [diff] [blame] | 73 | |
| 74 | target_add_scatter_file(tfm_ns ${CONFIG_SPE_PATH}/platform/linker_scripts) |
| 75 | |
| 76 | target_link_options(tfm_ns |
| 77 | PRIVATE |
| 78 | $<$<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^] | 79 | $<$<C_COMPILER_ID:ARMClang>:--map> |
David Hu | 1c1b816 | 2023-10-14 22:31:01 +0800 | [diff] [blame] | 80 | ) |
David Hu | e90feae | 2023-10-14 15:17:44 +0800 | [diff] [blame] | 81 | |
| 82 | add_convert_to_bin_target(tfm_ns) |