Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 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. |
| 22 | set(ATTESTATION_TEST_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 23 | if(NOT DEFINED TFM_ROOT_DIR) |
| 24 | message(FATAL_ERROR "Please set TFM_ROOT_DIR before including this file.") |
| 25 | endif() |
| 26 | |
| 27 | if (NOT DEFINED ATTEST_INCLUDE_TEST_CODE) |
| 28 | message(FATAL_ERROR "Incomplete build configuration: ATTEST_INCLUDE_TEST_CODE is undefined. ") |
| 29 | endif() |
| 30 | |
| 31 | if (NOT DEFINED ATTEST_CLAIM_VALUE_CHECK) |
| 32 | message(FATAL_ERROR "Incomplete build configuration: ATTEST_CLAIM_VALUE_CHECK is undefined. ") |
| 33 | endif() |
| 34 | |
| 35 | if (NOT DEFINED ENABLE_ATTESTATION_SERVICE_TESTS) |
| 36 | message(FATAL_ERROR "Incomplete build configuration: ENABLE_ATTESTATION_SERVICE_TESTS is undefined. ") |
| 37 | elseif(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 Ban | dffa27d | 2020-08-31 12:23:43 +0100 | [diff] [blame^] | 52 | "${ATTESTATION_TEST_DIR}/secure/attest_symmetric_s_interface_testsuite.c" |
| 53 | "${ATTESTATION_TEST_DIR}/attest_token_decode_symmetric.c" |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 54 | ) |
| 55 | list(APPEND ATTEST_TEST_SRC_NS |
Tamas Ban | dffa27d | 2020-08-31 12:23:43 +0100 | [diff] [blame^] | 56 | "${ATTESTATION_TEST_DIR}/non_secure/attest_symmetric_ns_interface_testsuite.c" |
| 57 | "${ATTESTATION_TEST_DIR}/attest_token_decode_symmetric.c" |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 58 | ) |
| 59 | else() |
| 60 | list(APPEND ATTEST_TEST_SRC_S |
Tamas Ban | dffa27d | 2020-08-31 12:23:43 +0100 | [diff] [blame^] | 61 | "${ATTESTATION_TEST_DIR}/secure/attest_asymmetric_s_interface_testsuite.c" |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 62 | "${ATTESTATION_TEST_DIR}/attest_public_key.c" |
Tamas Ban | dffa27d | 2020-08-31 12:23:43 +0100 | [diff] [blame^] | 63 | "${ATTESTATION_TEST_DIR}/attest_token_decode_asymmetric.c" |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 64 | ) |
| 65 | list(APPEND ATTEST_TEST_SRC_NS |
Tamas Ban | dffa27d | 2020-08-31 12:23:43 +0100 | [diff] [blame^] | 66 | "${ATTESTATION_TEST_DIR}/non_secure/attest_asymmetric_ns_interface_testsuite.c" |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 67 | "${ATTESTATION_TEST_DIR}/attest_public_key.c" |
Tamas Ban | dffa27d | 2020-08-31 12:23:43 +0100 | [diff] [blame^] | 68 | "${ATTESTATION_TEST_DIR}/attest_token_decode_asymmetric.c" |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 69 | ) |
| 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) |
| 95 | endif() |