-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCMakeLists.txt
125 lines (108 loc) · 3.68 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mbed-os CACHE INTERNAL "")
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
set(APP_TARGET mbed-os-tf-m-regression-tests)
include(${MBED_PATH}/tools/cmake/app.cmake)
project(${APP_TARGET})
add_subdirectory(${MBED_PATH})
add_executable(${APP_TARGET})
target_sources(${APP_TARGET}
PRIVATE
main.cpp
)
# Note: This is needed because TARGET_** is part of a list instead
# of a standalone variable, and it controls the path visibility
# for Mbed CLI 1. Once Mbed CLI 1 is deprecated, we can simplify
# the path to tfm/targets/${APP_TARGET}/device.
if(${MBED_TARGET} STREQUAL "ARM_MUSCA_B1")
set(TFM_TARGET_INCLUDE tfm/targets/TARGET_ARM_SSG/TARGET_MUSCA_B1/device)
elseif(${MBED_TARGET} STREQUAL "ARM_MUSCA_S1")
set(TFM_TARGET_INCLUDE tfm/targets/TARGET_ARM_SSG/TARGET_MUSCA_S1/device)
elseif(${MBED_TARGET} STREQUAL "NU_M2354")
set(TFM_TARGET_INCLUDE tfm/targets/TARGET_NUVOTON/TARGET_NU_M2354/device)
else()
message(FATAL_ERROR "Unsupported target ${MBED_TARGET}")
endif()
target_include_directories(${APP_TARGET}
PRIVATE
tfm/platform/include
${TFM_TARGET_INCLUDE}
test/inc
)
target_link_libraries(${APP_TARGET}
PRIVATE
mbed-os
mbed-psa
mbed-unity
mbed-utest
mbed-greentea-io
greentea::client_userio
)
if ("${MBED_CONFIG_DEFINITIONS}" MATCHES "MBED_CONF_APP_REGRESSION_TEST=1")
set(TEST_LIBS
# Note: To link successfully the order is important and reflects dependency.
# In general: test entry point -> suites -> platform -> utilities.
tfm_test_suite_core_ns
tfm_test_suite_attestation_ns
tfm_test_suite_crypto_ns
tfm_test_suite_ipc_ns
tfm_test_suite_its_ns
tfm_test_suite_platform_ns
tfm_test_suite_ps_ns
tfm_test_suite_qcbor_ns
tfm_test_suite_t_cose_ns
tfm_qcbor_test
tfm_t_cose_test
platform_ns
tfm_ns_integration_test
tfm_qcbor
)
# Firmware Update test supports Musca B1 and NU_M2354
if((${MBED_TARGET} STREQUAL ARM_MUSCA_B1) OR (${MBED_TARGET} STREQUAL NU_M2354))
list(APPEND TEST_LIBS
tfm_test_suite_fwu_ns
tfm_api_ns
)
endif()
# IRQ test only supports Musca B1
if(${MBED_TARGET} STREQUAL ARM_MUSCA_B1)
list(APPEND TEST_LIBS tfm_test_suite_irq)
endif()
elseif ("${MBED_CONFIG_DEFINITIONS}" MATCHES "MBED_CONF_APP_PSA_COMPLIANCE_TEST=1")
set(TEST_LIBS
val_nspe
pal_nspe
test_combine
)
else()
message(FATAL_ERROR "No test enabled in mbed_app.json")
endif()
# Note: The path transformation is required because `.ar` is not
# recognized by `-l<name>` of either toolchains. This extension
# is a legacy of Mbed CLI 1. In the future we should use `.a` for
# both toolchains, and take advantage of target_link_directories()
# so each `lib<name>.a` simply becomes `<name>` in target_link_libraries().
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
set(LIB_SUFFIX ".a")
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
set(LIB_SUFFIX ".ar")
else()
message(FATAL_ERROR "Unsupported toolchain ${MBED_TOOLCHAIN}")
endif()
list(TRANSFORM TEST_LIBS
PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/test/lib/TOOLCHAIN_${MBED_TOOLCHAIN}/lib"
)
list(TRANSFORM TEST_LIBS
APPEND "${LIB_SUFFIX}"
)
target_link_libraries(${APP_TARGET}
PRIVATE
${TEST_LIBS}
)
mbed_set_post_build(${APP_TARGET})
option(VERBOSE_BUILD "Have a verbose build process")
if(VERBOSE_BUILD)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()