blob: 13a8f08a7417c2ece0af8ab8ddcfc6f964219be9 [file] [log] [blame]
Anton Komlev84283b02023-08-16 10:57:56 +01001#-------------------------------------------------------------------------------
2# Copyright (c) 2023, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7cmake_minimum_required(VERSION 3.15)
8
David Hub4c9f9f2023-10-14 15:38:03 +08009# 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.
14if(POLICY CMP0123)
15 cmake_policy(SET CMP0123 NEW)
16endif()
17
Anton Komlev84283b02023-08-16 10:57:56 +010018if (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=")
20endif()
21
David Hu7042a262023-10-14 23:47:29 +080022list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../cmake)
23list(APPEND CMAKE_MODULE_PATH ${CONFIG_SPE_PATH}/cmake)
David Hu479ef002023-10-20 14:44:32 +080024list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/utils)
David Hu7042a262023-10-14 23:47:29 +080025include(remote_library)
26include(toolchain_selection)
Jianliang Shene8525112023-10-20 17:18:43 +080027include(utils)
Anton Komlev84283b02023-08-16 10:57:56 +010028
David Hu1ffdcfe2023-10-13 14:52:40 +080029# A platform sprecific MCPU and architecture flags for NS side
30include(${CONFIG_SPE_PATH}/platform/cpuarch.cmake)
David Hua1de7d62023-10-26 11:18:11 +080031# Include common configs exported from TF-M
32include(${CONFIG_SPE_PATH}/cmake/spe_config.cmake)
Kevin Peng21613562023-09-04 14:39:28 +080033# Platform abilities for example IRQ test support status
34include(${CONFIG_SPE_PATH}/platform/config.cmake OPTIONAL)
Jianliang Shene8525112023-10-20 17:18:43 +080035# Include coprocessor configs
36include(${CONFIG_SPE_PATH}/config/cp_config_default.cmake)
37
Jianliang Shene8525112023-10-20 17:18:43 +080038include(${TFM_TOOLCHAIN_FILE})
39project(tfm_ns LANGUAGES C ASM)
40tfm_toolchain_reload_compiler()
41
David Hua1de7d62023-10-26 11:18:11 +080042# If config_ns_test.cmake is exported from TF-M build, it indicates regression tests are enabled.
43# Otherwise, skip test configuration
Kevin Peng10a62012023-11-01 15:18:54 +080044include(${CONFIG_SPE_PATH}/config/config_ns_test.cmake OPTIONAL)
David Hua1de7d62023-10-26 11:18:11 +080045if(TFM_NS_REG_TEST)
46 # Include platform specific regression tests config
47 include(${CONFIG_SPE_PATH}/platform/tests/tfm_tests_config.cmake OPTIONAL)
48 if (TFM_PROFILE)
49 include(${CMAKE_CURRENT_LIST_DIR}/test/config/profile/${TFM_PROFILE}_test.cmake)
50 endif()
51 # Default test configurations
52 include(${CMAKE_CURRENT_LIST_DIR}/test/config/default_test_config.cmake)
53 # Config check in case additional test configs passed in via command line.
54 include(${CMAKE_CURRENT_LIST_DIR}/test/config/check_config.cmake)
Kevin Peng4216aa02023-10-27 17:04:42 +080055endif()
Jianliang Shene8525112023-10-20 17:18:43 +080056# Include coprocessor check to make sure NS toolchain is compatiable
57include(${CONFIG_SPE_PATH}/config/cp_check.cmake)
Anton Komlev84283b02023-08-16 10:57:56 +010058
59add_executable(tfm_ns)
60
David Hu87b46a82023-10-21 23:23:42 +080061add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../lib/ext ${CMAKE_BINARY_DIR}/lib/ext)
Anton Komlevc0ad6042023-08-29 18:23:26 +010062add_subdirectory(../app_broker ${CMAKE_BINARY_DIR}/app_broker)
David Hu479ef002023-10-20 14:44:32 +080063if(TFM_NS_REG_TEST)
64 add_subdirectory(test/ns_regression)
65endif()
Anton Komlev84283b02023-08-16 10:57:56 +010066
67############################# TFM NS main app ##################################
68
69target_sources(tfm_ns
70 PRIVATE
71 test_app.c
Kevin Peng9dff9862023-10-09 11:06:08 +080072 $<$<BOOL:${CONFIG_GNU_SYSCALL_STUB_ENABLED}>:../app_broker/syscalls_stub.c>
Anton Komlev84283b02023-08-16 10:57:56 +010073)
74
75target_link_libraries(tfm_ns
76 PRIVATE
77 tfm_test_broker
David Hu479ef002023-10-20 14:44:32 +080078 $<$<BOOL:${TFM_NS_REG_TEST}>:tfm_ns_tests>
79)
80
81target_compile_definitions(tfm_ns
82 PUBLIC
83 $<$<BOOL:${TFM_NS_REG_TEST}>:TFM_NS_REG_TEST>
Anton Komlev84283b02023-08-16 10:57:56 +010084)
85
86set_target_properties(tfm_ns PROPERTIES
87 SUFFIX ".axf"
88 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
89)
David Hu1c1b8162023-10-14 22:31:01 +080090
91target_add_scatter_file(tfm_ns ${CONFIG_SPE_PATH}/platform/linker_scripts)
92
93target_link_options(tfm_ns
94 PRIVATE
95 $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_ns.map>
David Hub4c9f9f2023-10-14 15:38:03 +080096 $<$<C_COMPILER_ID:ARMClang>:--map>
David Huc758b1e2023-11-01 14:51:03 +080097 $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_ns.map>
David Hu1c1b8162023-10-14 22:31:01 +080098)
David Hue90feae2023-10-14 15:17:44 +080099
100add_convert_to_bin_target(tfm_ns)