Build: Add qcbor library fetching
Change-Id: I00e8a0b6d551d01b39ca2d563ed9a75b9c4f2b72
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/lib/ext/CMakeLists.txt b/lib/ext/CMakeLists.txt
index eb53c97..d6da886 100644
--- a/lib/ext/CMakeLists.txt
+++ b/lib/ext/CMakeLists.txt
@@ -8,3 +8,8 @@
if(CONFIG_TFM_ERPC_TEST_FRAMEWORK)
add_subdirectory(erpc)
endif()
+
+if(TEST_NS_ATTESTATION OR TEST_NS_QCBOR)
+ add_subdirectory(qcbor)
+endif()
+
diff --git a/lib/ext/qcbor/CMakeLists.txt b/lib/ext/qcbor/CMakeLists.txt
new file mode 100644
index 0000000..1ac8401
--- /dev/null
+++ b/lib/ext/qcbor/CMakeLists.txt
@@ -0,0 +1,36 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020-2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+cmake_minimum_required(VERSION 3.15)
+
+if(NOT TEST_NS_ATTESTATION AND NOT TEST_NS_QCBOR)
+ return()
+endif()
+
+include(FetchContent)
+set(FETCHCONTENT_QUIET FALSE)
+
+# Default configuration of QCBOR repository
+set(QCBOR_PATH "DOWNLOAD" CACHE PATH "Path to qcbor (or DOWNLOAD to fetch automatically")
+set(QCBOR_VERSION "v1.2" CACHE STRING "The version of qcbor to use")
+
+# Entirely disable the floating-point support
+# in the qcbor library to reduce code size.
+set(QCBOR_OPT_DISABLE_FLOAT_HW_USE ON CACHE BOOL "Eliminate dependency on FP hardware and FP instructions" FORCE)
+set(QCBOR_OPT_DISABLE_FLOAT_PREFERRED ON CACHE BOOL "Eliminate support for half-precision and CBOR preferred serialization" FORCE)
+set(QCBOR_OPT_DISABLE_FLOAT_ALL ON CACHE BOOL "Eliminate floating-point support completely" FORCE)
+
+fetch_remote_library(
+ LIB_NAME qcbor
+ LIB_SOURCE_PATH_VAR QCBOR_PATH
+ LIB_PATCH_DIR ${CMAKE_CURRENT_LIST_DIR}
+ LIB_BASE_DIR "${CMAKE_BINARY_DIR}/lib/ext"
+ FETCH_CONTENT_ARGS
+ GIT_REPOSITORY https://github.com/laurencelundblade/QCBOR.git
+ GIT_TAG ${QCBOR_VERSION}
+ GIT_PROGRESS TRUE
+)