1project (xtest C)
2
3include(${OPTEE_TEST_SDK}/host_include/conf.cmake)
4
5################################################################################
6# Packages
7################################################################################
8find_package(Threads REQUIRED)
9if(NOT THREADS_FOUND)
10	message(FATAL_ERROR "Threads not found")
11endif()
12
13find_package(OpenSSL)
14if(OPENSSL_FOUND)
15	add_compile_options(-DOPENSSL_FOUND=1)
16	set (OPENSSL_PRIVATE_LINK OpenSSL::Crypto)
17endif()
18
19add_compile_options(-D__OPTEE_CORE_API_COMPAT_1_1=1)
20
21find_package(Python REQUIRED)
22
23include(GNUInstallDirs)
24
25macro(EMBED_8100FILE prefix infile)
26	add_custom_command(
27		OUTPUT  regression_8100_${prefix}.h
28		COMMAND ${Python_EXECUTABLE} ${OPTEE_TEST_ROOT_DIR}/scripts/file_to_c.py --inf ${infile}
29	--out ${CMAKE_CURRENT_BINARY_DIR}/regression_8100_${prefix}.h
30	--name regression_8100_${prefix}
31		DEPENDS ${OPTEE_TEST_ROOT_DIR}/scripts/file_to_c.py ${infile}
32	)
33
34	set_property(SOURCE regression_8100.c APPEND PROPERTY OBJECT_DEPENDS
35		     ${CMAKE_CURRENT_BINARY_DIR}/regression_8100_${prefix}.h)
36endmacro(EMBED_8100FILE)
37
38EMBED_8100FILE(ca_crt ${OPTEE_TEST_ROOT_DIR}/cert/ca.crt)
39EMBED_8100FILE(mid_crt ${OPTEE_TEST_ROOT_DIR}/cert/mid.crt)
40EMBED_8100FILE(my_crt ${OPTEE_TEST_ROOT_DIR}/cert/my.crt)
41EMBED_8100FILE(my_csr ${OPTEE_TEST_ROOT_DIR}/cert/my.csr)
42
43set (SRC
44	adbg/src/adbg_case.c
45	adbg/src/adbg_enum.c
46	adbg/src/adbg_expect.c
47	adbg/src/adbg_log.c
48	adbg/src/adbg_run.c
49	adbg/src/security_utils_hex.c
50	aes_perf.c
51	benchmark_1000.c
52	benchmark_2000.c
53	regression_1000.c
54	regression_4000.c
55	regression_4100.c
56	regression_5000.c
57	regression_6000.c
58	regression_8000.c
59	regression_8100.c
60	hash_perf.c
61	stats.c
62	xtest_helpers.c
63	xtest_main.c
64	xtest_test.c
65	xtest_uuid_helpers.c
66)
67if(CFG_SECURE_PARTITION AND CFG_SPMC_TESTS)
68	list (APPEND SRC ffa_spmc_1000.c)
69endif()
70
71if (WITH_GP_TESTS)
72	add_compile_options(-DWITH_GP_TESTS=1)
73
74	macro(__GEN_GP_FILE outfile xmldir name basedir)
75		add_custom_command(
76			OUTPUT	${outfile}
77			COMMAND	xalan -in ${basedir}/${name}.xml
78				      -xsl gp/${name}.xsl -out ${outfile}
79			DEPENDS ${basedir}/${name}.xml gp/${name}.xsl
80		)
81	endmacro(__GEN_GP_FILE)
82	macro(GEN_GP_FILE outfile xmldir name)
83		__GEN_GP_FILE(${outfile} ${xmldir} ${name}
84			      gp-suite/packages/${xmldir})
85		list (APPEND SRC ${outfile})
86	endmacro(GEN_GP_FILE)
87
88	GEN_GP_FILE(gp_10000.c ClientAPI/xmlstable TEE)
89	GEN_GP_FILE(gp_20000.c TrustedCoreFw/xmlstable TEE_Internal_API)
90	GEN_GP_FILE(gp_30000.c DataStorage/xmlstable TEE_DataStorage_API)
91	GEN_GP_FILE(gp_40000.c Time_Arithmetical/xmlstable TEE_TimeArithm_API)
92	GEN_GP_FILE(gp_50000.c Crypto/xmlstable TEE_Crypto_API)
93	set (GP_INCLUDES PRIVATE gp/include)
94endif()
95
96if (CFG_GP_SOCKETS)
97	list (APPEND SRC
98		regression_2000.c
99		sock_server.c
100		rand_stream.c
101	)
102endif()
103
104if (CFG_SECSTOR_TA_MGMT_PTA)
105	list (APPEND SRC install_ta.c)
106endif()
107
108if (CFG_SECURE_DATA_PATH)
109	list (APPEND SRC sdp_basic.c)
110endif()
111
112if (CFG_PKCS11_TA)
113	add_compile_options(-DCFG_PKCS11_TA)
114	list (APPEND SRC pkcs11_1000.c)
115endif()
116
117if (CFG_CRYPTO_SE05X)
118	add_compile_options(-DCFG_CRYPTO_SE05X)
119endif()
120
121################################################################################
122# Built binary
123################################################################################
124add_executable (${PROJECT_NAME} ${SRC})
125
126target_compile_options (${PROJECT_NAME} PRIVATE -include conf.h)
127
128target_include_directories(${PROJECT_NAME}
129	PRIVATE .
130	PRIVATE ../supp_plugin/include
131	PRIVATE adbg/include
132	PRIVATE ${OPTEE_TEST_SDK}/host_include
133	PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
134	${GP_INCLUDES}
135)
136
137target_link_libraries (${PROJECT_NAME}
138	PRIVATE ${CMAKE_THREAD_LIBS_INIT}
139	PRIVATE xtest-ta-headers
140	PRIVATE teec
141	PRIVATE m
142	PRIVATE ${OPENSSL_PRIVATE_LINK}
143	PRIVATE ckteec
144)
145
146################################################################################
147# Install targets
148################################################################################
149install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
150