blob: 46744d41a2fcd2c26491e43e986b17da1a19fa53 [file] [log] [blame]
Kevin Peng62a87112020-07-07 15:07:46 +08001#-------------------------------------------------------------------------------
2# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8#Definitions to compile the "secure attestation test" module.
9#This file assumes it will be included from a project specific cmakefile, and
10#will not create a library or executable.
11#Inputs:
12# TFM_ROOT_DIR - root directory of the TF-M repo.
13#
14#Outputs:
15# Will modify include directories to make the source compile.
16# ALL_SRC_C: C source files to be compiled will be added to this list. This shall be added to your add_executable or add_library command.
17# ALL_SRC_CXX: C++ source files to be compiled will be added to this list. This shall be added to your add_executable or add_library command.
18# ALL_SRC_ASM: assembly source files to be compiled will be added to this list. This shall be added to your add_executable or add_library command.
19# Include directories will be modified by using the include_directories() commands as needed.
20
21#Get the current directory where this file is located.
22set(ATTESTATION_TEST_DIR ${CMAKE_CURRENT_LIST_DIR})
23if(NOT DEFINED TFM_ROOT_DIR)
24 message(FATAL_ERROR "Please set TFM_ROOT_DIR before including this file.")
25endif()
26
27if (NOT DEFINED ATTEST_INCLUDE_TEST_CODE)
28 message(FATAL_ERROR "Incomplete build configuration: ATTEST_INCLUDE_TEST_CODE is undefined. ")
29endif()
30
31if (NOT DEFINED ATTEST_CLAIM_VALUE_CHECK)
32 message(FATAL_ERROR "Incomplete build configuration: ATTEST_CLAIM_VALUE_CHECK is undefined. ")
33endif()
34
35if (NOT DEFINED ENABLE_ATTESTATION_SERVICE_TESTS)
36 message(FATAL_ERROR "Incomplete build configuration: ENABLE_ATTESTATION_SERVICE_TESTS is undefined. ")
37elseif(ENABLE_ATTESTATION_SERVICE_TESTS)
38 list(APPEND ATTEST_TEST_SRC_S
39 "${ATTESTATION_TEST_DIR}/attest_token_test.c"
40 "${ATTESTATION_TEST_DIR}/attest_token_decode_common.c"
41 "${TFM_ROOT_DIR}/lib/ext/qcbor/util/qcbor_util.c"
42 )
43
44 list(APPEND ATTEST_TEST_SRC_NS
45 "${ATTESTATION_TEST_DIR}/attest_token_test.c"
46 "${ATTESTATION_TEST_DIR}/attest_token_decode_common.c"
47 "${TFM_ROOT_DIR}/lib/ext/qcbor/util/qcbor_util.c"
48 )
49
50 if (SYMMETRIC_INITIAL_ATTESTATION)
51 list(APPEND ATTEST_TEST_SRC_S
Tamas Bandffa27d2020-08-31 12:23:43 +010052 "${ATTESTATION_TEST_DIR}/secure/attest_symmetric_s_interface_testsuite.c"
53 "${ATTESTATION_TEST_DIR}/attest_token_decode_symmetric.c"
Kevin Peng62a87112020-07-07 15:07:46 +080054 )
55 list(APPEND ATTEST_TEST_SRC_NS
Tamas Bandffa27d2020-08-31 12:23:43 +010056 "${ATTESTATION_TEST_DIR}/non_secure/attest_symmetric_ns_interface_testsuite.c"
57 "${ATTESTATION_TEST_DIR}/attest_token_decode_symmetric.c"
Kevin Peng62a87112020-07-07 15:07:46 +080058 )
59 else()
60 list(APPEND ATTEST_TEST_SRC_S
Tamas Bandffa27d2020-08-31 12:23:43 +010061 "${ATTESTATION_TEST_DIR}/secure/attest_asymmetric_s_interface_testsuite.c"
Kevin Peng62a87112020-07-07 15:07:46 +080062 "${ATTESTATION_TEST_DIR}/attest_public_key.c"
Tamas Bandffa27d2020-08-31 12:23:43 +010063 "${ATTESTATION_TEST_DIR}/attest_token_decode_asymmetric.c"
Kevin Peng62a87112020-07-07 15:07:46 +080064 )
65 list(APPEND ATTEST_TEST_SRC_NS
Tamas Bandffa27d2020-08-31 12:23:43 +010066 "${ATTESTATION_TEST_DIR}/non_secure/attest_asymmetric_ns_interface_testsuite.c"
Kevin Peng62a87112020-07-07 15:07:46 +080067 "${ATTESTATION_TEST_DIR}/attest_public_key.c"
Tamas Bandffa27d2020-08-31 12:23:43 +010068 "${ATTESTATION_TEST_DIR}/attest_token_decode_asymmetric.c"
Kevin Peng62a87112020-07-07 15:07:46 +080069 )
70 endif()
71
72 if (ATTEST_INCLUDE_TEST_CODE)
73 set_property(SOURCE ${ATTEST_TEST_SRC_S} APPEND PROPERTY COMPILE_DEFINITIONS INCLUDE_TEST_CODE)
74 set_property(SOURCE ${ATTEST_TEST_SRC_NS} APPEND PROPERTY COMPILE_DEFINITIONS INCLUDE_TEST_CODE)
75 endif()
76
77 if (ATTEST_CLAIM_VALUE_CHECK)
78 set_property(SOURCE ${ATTEST_TEST_SRC_S} APPEND PROPERTY COMPILE_DEFINITIONS CLAIM_VALUE_CHECK)
79 set_property(SOURCE ${ATTEST_TEST_SRC_NS} APPEND PROPERTY COMPILE_DEFINITIONS CLAIM_VALUE_CHECK)
80 endif()
81
82 #Setting include directories
83 embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE)
84 embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE)
85 embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/partitions/initial_attestation ABSOLUTE)
86 embedded_include_directories(PATH ${TFM_ROOT_DIR}/lib/ext/qcbor/inc ABSOLUTE)
87 embedded_include_directories(PATH ${TFM_ROOT_DIR}/lib/ext/qcbor/util ABSOLUTE)
88 embedded_include_directories(PATH ${TFM_ROOT_DIR}/lib/ext/t_cose/inc ABSOLUTE)
89
90 #Append all our source files to global lists.
91 list(APPEND ALL_SRC_C_S ${ATTEST_TEST_SRC_S})
92 list(APPEND ALL_SRC_C_NS ${ATTEST_TEST_SRC_NS})
93 unset(ATTEST_TEST_SRC_S)
94 unset(ATTEST_TEST_SRC_NS)
95endif()