Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Marc Moreno Berengue | 3587a9f | 2019-01-14 15:56:46 +0000 | [diff] [blame] | 2 | # Copyright (c) 2017-2019, Arm Limited. All rights reserved. |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | cmake_minimum_required(VERSION 3.7) |
| 9 | |
| 10 | #Tell cmake where our modules can be found |
| 11 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake) |
| 12 | |
Ken Liu | e40f9a2 | 2019-06-03 16:42:47 +0800 | [diff] [blame^] | 13 | #Tell TFM Root before calling sub cmake |
| 14 | get_filename_component(TFM_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) |
| 15 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 16 | #Include common stuff to control cmake. |
| 17 | include("Common/BuildSys") |
| 18 | |
| 19 | #Start an embedded project. |
Ken Liu | e40f9a2 | 2019-06-03 16:42:47 +0800 | [diff] [blame^] | 20 | embedded_project_start(CONFIG "${TFM_ROOT_DIR}/configs/ConfigDefault.cmake") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 21 | project(tfm_tests LANGUAGES ASM C) |
| 22 | embedded_project_fixup() |
| 23 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 24 | #Check incoming configuration options |
| 25 | if (NOT DEFINED SERVICES_TEST_ENABLED) |
| 26 | message(FATAL_ERROR "Incomplete build configuration: SERVICES_TEST_ENABLED is undefined. ") |
| 27 | endif() |
| 28 | |
Tamas Ban | 3109b30 | 2018-08-15 14:51:58 +0100 | [diff] [blame] | 29 | if (NOT DEFINED CORE_TEST_INTERACTIVE) |
| 30 | message(FATAL_ERROR "Incomplete build configuration: CORE_TEST_INTERACTIVE is undefined. ") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 31 | endif() |
| 32 | |
Tamas Ban | 3109b30 | 2018-08-15 14:51:58 +0100 | [diff] [blame] | 33 | if (NOT DEFINED CORE_TEST_POSITIVE) |
| 34 | message(FATAL_ERROR "Incomplete build configuration: CORE_TEST_POSITIVE is undefined. ") |
| 35 | endif() |
| 36 | |
| 37 | if (NOT DEFINED TFM_LVL) |
| 38 | message(FATAL_ERROR "Incomplete build configuration: TFM_LVL is undefined. ") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 39 | endif() |
| 40 | |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 41 | if (NOT DEFINED TFM_PARTITION_AUDIT_LOG) |
| 42 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_AUDIT_LOG is undefined.") |
| 43 | endif() |
| 44 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 45 | #Configure our options as needed. |
| 46 | if (CORE_TEST_INTERACTIVE OR CORE_TEST_POSITIVE) |
| 47 | set(ENABLE_CORE_TESTS True) |
| 48 | set(ENABLE_CORE_TESTS_2 True) |
| 49 | else() |
| 50 | set(ENABLE_CORE_TESTS False) |
| 51 | set(ENABLE_CORE_TESTS_2 False) |
| 52 | endif() |
| 53 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 54 | set(ENABLE_SECURE_STORAGE_SERVICE_TESTS TRUE) |
Antonio de Angelis | 7852dff | 2018-02-07 11:15:54 +0000 | [diff] [blame] | 55 | set(ENABLE_AUDIT_LOGGING_SERVICE_TESTS TRUE) |
Antonio de Angelis | 88c5b27 | 2018-08-31 15:48:21 +0100 | [diff] [blame] | 56 | set(ENABLE_CRYPTO_SERVICE_TESTS TRUE) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 57 | set(ENABLE_INVERT_SERVICE_TESTS TRUE) |
Tamas Ban | 229f9db | 2018-08-17 12:57:13 +0100 | [diff] [blame] | 58 | set(ENABLE_ATTESTATION_SERVICE_TESTS TRUE) |
Tamas Ban | aaf9039 | 2019-01-02 13:24:13 +0000 | [diff] [blame] | 59 | set(ENABLE_QCBOR_TESTS TRUE) |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 60 | |
| 61 | if (NOT TFM_PARTITION_AUDIT_LOG) |
| 62 | set(ENABLE_AUDIT_LOGGING_SERVICE_TESTS FALSE) |
| 63 | endif() |
| 64 | |
| 65 | if (ENABLE_AUDIT_LOGGING_SERVICE_TESTS) |
| 66 | set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ENABLE_AUDIT_LOGGING_SERVICE_TESTS) |
| 67 | endif() |
| 68 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 69 | include(${CMAKE_CURRENT_LIST_DIR}/CMakeLists.inc) |
| 70 | |
Laurence Lundblade | dada123 | 2019-03-01 09:13:14 -0800 | [diff] [blame] | 71 | if (NOT TARGET tfm_t_cose_verify) |
| 72 | add_subdirectory(${TFM_ROOT_DIR}/lib/t_cose ${CMAKE_CURRENT_BINARY_DIR}/t_cose) |
| 73 | endif() |
| 74 | |
Tamas Ban | a4574d9 | 2019-03-06 14:21:33 +0000 | [diff] [blame] | 75 | if (NOT TARGET tfm_qcbor) |
| 76 | add_subdirectory(${TFM_ROOT_DIR}/lib/ext/qcbor ${CMAKE_CURRENT_BINARY_DIR}/qcbor) |
| 77 | endif() |
| 78 | |
| 79 | #Build the secure library. Even though secure tests files depend on tfm_qcbor, |
| 80 | #this is not expressed here as the tfm_attest library is expected to hold the |
| 81 | #compiled tfm_qcbor files. |
Laurence Lundblade | dada123 | 2019-03-01 09:13:14 -0800 | [diff] [blame] | 82 | add_library(tfm_secure_tests STATIC ${ALL_SRC_C} ${ALL_SRC_C_S} $<TARGET_OBJECTS:tfm_t_cose_verify>) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 83 | |
| 84 | #Set common compiler and linker flags |
| 85 | config_setting_shared_compiler_flags(tfm_secure_tests) |
| 86 | config_setting_shared_linker_flags(tfm_secure_tests) |
| 87 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 88 | embedded_set_target_compile_defines(TARGET tfm_secure_tests LANGUAGE C DEFINES __thumb2__ __ARM_FEATURE_CMSE=3 TFM_LVL=${TFM_LVL} APPEND) |
| 89 | |
| 90 | |
| 91 | #Build the non-secure library |
| 92 | set(CMAKE_STATIC_LIBRARY_PREFIX_C "lib") |
Tamas Ban | a4574d9 | 2019-03-06 14:21:33 +0000 | [diff] [blame] | 93 | add_library(tfm_non_secure_tests STATIC ${ALL_SRC_C} ${ALL_SRC_C_NS} $<TARGET_OBJECTS:tfm_t_cose_verify> $<TARGET_OBJECTS:tfm_qcbor>) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 94 | |
| 95 | #Set common compiler and linker flags |
| 96 | config_setting_shared_compiler_flags(tfm_non_secure_tests) |
| 97 | config_setting_shared_linker_flags(tfm_non_secure_tests) |
| 98 | |
Tamas Ban | d90c81b | 2018-08-15 15:03:42 +0100 | [diff] [blame] | 99 | embedded_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 Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 100 | #__DOMAIN_NS=1 |
| 101 | |
| 102 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 103 | set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Default install location for tfm_storage." FORCE) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 104 | endif() |
| 105 | |
Tamas Ban | c2074a7 | 2018-08-14 10:23:12 +0100 | [diff] [blame] | 106 | install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/framework/test_framework_integ_test.h |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 107 | ${CMAKE_CURRENT_SOURCE_DIR}/suites/sst/non_secure/os_wrapper.h |
Antonio De Angelis | 6085ff0 | 2019-02-20 15:18:40 +0000 | [diff] [blame] | 108 | ${CMAKE_CURRENT_SOURCE_DIR}/test_services/tfm_secure_client_service/tfm_secure_client_service_api.h |
| 109 | DESTINATION export/tfm/test/inc) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 110 | |
| 111 | install(TARGETS tfm_non_secure_tests |
Tamas Ban | 57bfa43 | 2018-04-13 16:05:49 +0100 | [diff] [blame] | 112 | DESTINATION export/tfm/test/lib |
| 113 | PUBLIC_HEADER DESTINATION export/tfm/test/inc) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 114 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 115 | embedded_project_end(tfm_non_secure_tests) |
| 116 | embedded_project_end(tfm_secure_tests) |