1#-------------------------------------------------------------------------------
2# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7cmake_policy(SET CMP0079 NEW)
8
9####################### qcbor ns ###############################################
10
11add_library(tfm_qcbor_ns STATIC EXCLUDE_FROM_ALL)
12
13target_sources(tfm_qcbor_ns
14    PRIVATE
15        ${QCBOR_PATH}/src/ieee754.c
16        ${QCBOR_PATH}/src/qcbor_encode.c
17        ${QCBOR_PATH}/src/qcbor_decode.c
18        ${QCBOR_PATH}/src/UsefulBuf.c
19)
20
21target_include_directories(tfm_qcbor_ns
22    PUBLIC
23        $<BUILD_INTERFACE:${QCBOR_PATH}/inc>
24    INTERFACE
25        $<BUILD_INTERFACE:${QCBOR_PATH}/inc/qcbor>
26)
27
28target_link_libraries(tfm_qcbor_ns
29    PRIVATE
30        tfm_t_cose_defs
31)
32
33target_compile_options(tfm_qcbor_ns
34    PUBLIC
35        ${COMPILER_CP_FLAG}
36)
37
38target_compile_definitions(tfm_qcbor_ns
39    PUBLIC
40        QCBOR_DISABLE_FLOAT_HW_USE
41        USEFULBUF_DISABLE_ALL_FLOAT
42        QCBOR_DISABLE_PREFERRED_FLOAT
43)
44
45####################### qcbor test #############################################
46
47add_library(tfm_qcbor_test STATIC EXCLUDE_FROM_ALL)
48
49target_sources(tfm_qcbor_test
50    PRIVATE
51        ${QCBOR_PATH}/test/qcbor_decode_tests.c
52        ${QCBOR_PATH}/test/qcbor_encode_tests.c
53        ${QCBOR_PATH}/test/run_tests.c
54        ${QCBOR_PATH}/test/UsefulBuf_Tests.c
55)
56
57target_include_directories(tfm_qcbor_test
58    PUBLIC
59        $<BUILD_INTERFACE:${QCBOR_PATH}/test>
60    PRIVATE
61        $<BUILD_INTERFACE:${QCBOR_PATH}/inc>
62)
63
64target_link_libraries(tfm_qcbor_test
65    PRIVATE
66        tfm_qcbor_ns
67)
68
69####################### Non Secure test ########################################
70
71if (NOT TEST_NS_QCBOR)
72    return()
73endif()
74
75add_library(tfm_test_suite_qcbor_ns STATIC EXCLUDE_FROM_ALL)
76
77target_sources(tfm_test_suite_qcbor_ns
78    PRIVATE
79        non_secure/qcbor_ns_testsuite.c
80)
81
82target_include_directories(tfm_test_suite_qcbor_ns
83    PUBLIC
84        non_secure
85        $<BUILD_INTERFACE:${QCBOR_PATH}/test>
86)
87
88target_compile_definitions(tfm_test_suite_qcbor_ns
89    PRIVATE
90        DOMAIN_NS=1
91    INTERFACE
92        TEST_NS_QCBOR
93)
94
95target_link_libraries(tfm_test_suite_qcbor_ns
96    PRIVATE
97        tfm_test_framework_ns
98        tfm_qcbor_test
99)
100
101target_link_libraries(tfm_ns_tests
102    INTERFACE
103        tfm_test_suite_qcbor_ns
104)
105