aboutsummaryrefslogtreecommitdiff
path: root/test/suites/attestation/CMakeLists.inc
blob: f761640e5846b3e67e94157c77314c5be5b2fda9 (plain)
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
#-------------------------------------------------------------------------------
# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
#-------------------------------------------------------------------------------

#Definitions to compile the "secure attestation test" module.
#This file assumes it will be included from a project specific cmakefile, and
#will not create a library or executable.
#Inputs:
#	TFM_ROOT_DIR - root directory of the TF-M repo.
#
#Outputs:
#	Will modify include directories to make the source compile.
#	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.
#	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.
#	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.
#	Include directories will be modified by using the include_directories() commands as needed.

#Get the current directory where this file is located.
set(ATTESTATION_TEST_DIR ${CMAKE_CURRENT_LIST_DIR})
if(NOT DEFINED TFM_ROOT_DIR)
	message(FATAL_ERROR "Please set TFM_ROOT_DIR before including this file.")
endif()

if (NOT DEFINED ATTEST_INCLUDE_TEST_CODE)
	message(FATAL_ERROR "Incomplete build configuration: ATTEST_INCLUDE_TEST_CODE is undefined. ")
endif()

if (NOT DEFINED ATTEST_CLAIM_VALUE_CHECK)
	message(FATAL_ERROR "Incomplete build configuration: ATTEST_CLAIM_VALUE_CHECK is undefined. ")
endif()

if (NOT DEFINED ENABLE_ATTESTATION_SERVICE_TESTS)
	message(FATAL_ERROR "Incomplete build configuration: ENABLE_ATTESTATION_SERVICE_TESTS is undefined. ")
elseif(ENABLE_ATTESTATION_SERVICE_TESTS)
	list(APPEND ATTEST_TEST_SRC_S
		"${ATTESTATION_TEST_DIR}/secure/attestation_s_interface_testsuite.c"
		"${ATTESTATION_TEST_DIR}/attest_token_test.c"
		"${ATTESTATION_TEST_DIR}/attest_token_decode_common.c"
		"${ATTESTATION_TEST_DIR}/attest_token_decode.c"
		"${ATTESTATION_TEST_DIR}/attest_public_key.c"
		"${TFM_ROOT_DIR}/lib/ext/qcbor/util/qcbor_util.c"
	)

	list(APPEND ATTEST_TEST_SRC_NS
		"${ATTESTATION_TEST_DIR}/non_secure/attestation_ns_interface_testsuite.c"
		"${ATTESTATION_TEST_DIR}/attest_token_test.c"
		"${ATTESTATION_TEST_DIR}/attest_token_decode_common.c"
		"${ATTESTATION_TEST_DIR}/attest_token_decode.c"
		"${ATTESTATION_TEST_DIR}/attest_public_key.c"
		"${TFM_ROOT_DIR}/lib/ext/qcbor/util/qcbor_util.c"
	)

	if (ATTEST_INCLUDE_TEST_CODE)
		set_property(SOURCE ${ATTEST_TEST_SRC_S}  APPEND PROPERTY COMPILE_DEFINITIONS INCLUDE_TEST_CODE)
		set_property(SOURCE ${ATTEST_TEST_SRC_NS} APPEND PROPERTY COMPILE_DEFINITIONS INCLUDE_TEST_CODE)
	endif()

	if (ATTEST_CLAIM_VALUE_CHECK)
		set_property(SOURCE ${ATTEST_TEST_SRC_S}  APPEND PROPERTY COMPILE_DEFINITIONS CLAIM_VALUE_CHECK)
		set_property(SOURCE ${ATTEST_TEST_SRC_NS} APPEND PROPERTY COMPILE_DEFINITIONS CLAIM_VALUE_CHECK)
	endif()

	#Setting include directories
	embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE)
	embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE)
	embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/partitions/initial_attestation ABSOLUTE)
	embedded_include_directories(PATH ${TFM_ROOT_DIR}/lib/ext/qcbor/inc ABSOLUTE)
	embedded_include_directories(PATH ${TFM_ROOT_DIR}/lib/ext/qcbor/util ABSOLUTE)
	embedded_include_directories(PATH ${TFM_ROOT_DIR}/lib/ext/t_cose/inc ABSOLUTE)

	#Append all our source files to global lists.
	list(APPEND ALL_SRC_C_S  ${ATTEST_TEST_SRC_S})
	list(APPEND ALL_SRC_C_NS ${ATTEST_TEST_SRC_NS})
	unset(ATTEST_TEST_SRC_S)
	unset(ATTEST_TEST_SRC_NS)
endif()