blob: 8f3fdf5740147907496cccd3fa6375fa4d60f8c5 [file] [log] [blame]
Gyorgy Szing30fa9872017-12-05 01:08:47 +00001#-------------------------------------------------------------------------------
Marc Moreno Berengue3587a9f2019-01-14 15:56:46 +00002# Copyright (c) 2017-2019, Arm Limited. All rights reserved.
Gyorgy Szing30fa9872017-12-05 01:08:47 +00003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8cmake_minimum_required(VERSION 3.7)
9
10#Tell cmake where our modules can be found
11list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake)
12
13#Include common stuff to control cmake.
14include("Common/BuildSys")
15
16#Start an embedded project.
17embedded_project_start(CONFIG "${CMAKE_CURRENT_LIST_DIR}/../ConfigDefault.cmake")
18project(tfm_tests LANGUAGES ASM C)
19embedded_project_fixup()
20
21get_filename_component(TFM_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
22
23#Check incoming configuration options
24if (NOT DEFINED SERVICES_TEST_ENABLED)
25 message(FATAL_ERROR "Incomplete build configuration: SERVICES_TEST_ENABLED is undefined. ")
26endif()
27
Tamas Ban3109b302018-08-15 14:51:58 +010028if (NOT DEFINED CORE_TEST_INTERACTIVE)
29 message(FATAL_ERROR "Incomplete build configuration: CORE_TEST_INTERACTIVE is undefined. ")
Gyorgy Szing30fa9872017-12-05 01:08:47 +000030endif()
31
Tamas Ban3109b302018-08-15 14:51:58 +010032if (NOT DEFINED CORE_TEST_POSITIVE)
33 message(FATAL_ERROR "Incomplete build configuration: CORE_TEST_POSITIVE is undefined. ")
34endif()
35
36if (NOT DEFINED TFM_LVL)
37 message(FATAL_ERROR "Incomplete build configuration: TFM_LVL is undefined. ")
Gyorgy Szing30fa9872017-12-05 01:08:47 +000038endif()
39
40#Configure our options as needed.
41if (CORE_TEST_INTERACTIVE OR CORE_TEST_POSITIVE)
42 set(ENABLE_CORE_TESTS True)
43 set(ENABLE_CORE_TESTS_2 True)
44else()
45 set(ENABLE_CORE_TESTS False)
46 set(ENABLE_CORE_TESTS_2 False)
47endif()
48
Gyorgy Szing30fa9872017-12-05 01:08:47 +000049set(ENABLE_SECURE_STORAGE_SERVICE_TESTS TRUE)
Antonio de Angelis7852dff2018-02-07 11:15:54 +000050set(ENABLE_AUDIT_LOGGING_SERVICE_TESTS TRUE)
Antonio de Angelis88c5b272018-08-31 15:48:21 +010051set(ENABLE_CRYPTO_SERVICE_TESTS TRUE)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000052set(ENABLE_INVERT_SERVICE_TESTS TRUE)
Tamas Ban229f9db2018-08-17 12:57:13 +010053set(ENABLE_ATTESTATION_SERVICE_TESTS TRUE)
Tamas Banaaf90392019-01-02 13:24:13 +000054set(ENABLE_QCBOR_TESTS TRUE)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000055include(${CMAKE_CURRENT_LIST_DIR}/CMakeLists.inc)
56
Laurence Lundbladedada1232019-03-01 09:13:14 -080057if (NOT TARGET tfm_t_cose_verify)
58 add_subdirectory(${TFM_ROOT_DIR}/lib/t_cose ${CMAKE_CURRENT_BINARY_DIR}/t_cose)
59endif()
60
Tamas Bana4574d92019-03-06 14:21:33 +000061if (NOT TARGET tfm_qcbor)
62 add_subdirectory(${TFM_ROOT_DIR}/lib/ext/qcbor ${CMAKE_CURRENT_BINARY_DIR}/qcbor)
63endif()
64
65#Build the secure library. Even though secure tests files depend on tfm_qcbor,
66#this is not expressed here as the tfm_attest library is expected to hold the
67#compiled tfm_qcbor files.
Laurence Lundbladedada1232019-03-01 09:13:14 -080068add_library(tfm_secure_tests STATIC ${ALL_SRC_C} ${ALL_SRC_C_S} $<TARGET_OBJECTS:tfm_t_cose_verify>)
Tamas Bandb69d522018-03-01 10:04:41 +000069
70#Set common compiler and linker flags
71config_setting_shared_compiler_flags(tfm_secure_tests)
72config_setting_shared_linker_flags(tfm_secure_tests)
73
Gyorgy Szing30fa9872017-12-05 01:08:47 +000074embedded_set_target_compile_defines(TARGET tfm_secure_tests LANGUAGE C DEFINES __thumb2__ __ARM_FEATURE_CMSE=3 TFM_LVL=${TFM_LVL} APPEND)
75
76
77#Build the non-secure library
78set(CMAKE_STATIC_LIBRARY_PREFIX_C "lib")
Tamas Bana4574d92019-03-06 14:21:33 +000079add_library(tfm_non_secure_tests STATIC ${ALL_SRC_C} ${ALL_SRC_C_NS} $<TARGET_OBJECTS:tfm_t_cose_verify> $<TARGET_OBJECTS:tfm_qcbor>)
Tamas Bandb69d522018-03-01 10:04:41 +000080
81#Set common compiler and linker flags
82config_setting_shared_compiler_flags(tfm_non_secure_tests)
83config_setting_shared_linker_flags(tfm_non_secure_tests)
84
Tamas Band90c81b2018-08-15 15:03:42 +010085embedded_set_target_compile_defines(TARGET tfm_non_secure_tests LANGUAGE C DEFINES __thumb2__ __ARM_FEATURE_CMSE=3 __DOMAIN_NS=1 TFM_LVL=${TFM_LVL} APPEND)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000086#__DOMAIN_NS=1
87
88if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
Tamas Bandb69d522018-03-01 10:04:41 +000089 set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Default install location for tfm_storage." FORCE)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000090endif()
91
Tamas Banc2074a72018-08-14 10:23:12 +010092install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/framework/test_framework_integ_test.h
Gyorgy Szing30fa9872017-12-05 01:08:47 +000093 ${CMAKE_CURRENT_SOURCE_DIR}/suites/sst/non_secure/os_wrapper.h
Antonio De Angelis6085ff02019-02-20 15:18:40 +000094 ${CMAKE_CURRENT_SOURCE_DIR}/test_services/tfm_secure_client_service/tfm_secure_client_service_api.h
95 DESTINATION export/tfm/test/inc)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000096
97install(TARGETS tfm_non_secure_tests
Tamas Ban57bfa432018-04-13 16:05:49 +010098 DESTINATION export/tfm/test/lib
99 PUBLIC_HEADER DESTINATION export/tfm/test/inc)
Gyorgy Szing30fa9872017-12-05 01:08:47 +0000100
Gyorgy Szing30fa9872017-12-05 01:08:47 +0000101embedded_project_end(tfm_non_secure_tests)
102embedded_project_end(tfm_secure_tests)