1#-------------------------------------------------------------------------------
2# Copyright (c) 2020-2023, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8cmake_minimum_required(VERSION 3.15)
9
10include(FetchContent)
11set(FETCHCONTENT_QUIET FALSE)
12
13# Default configuration of QCBOR repository
14set(QCBOR_PATH      "DOWNLOAD"  CACHE PATH      "Path to qcbor (or DOWNLOAD to fetch automatically")
15set(QCBOR_VERSION   "v1.2"      CACHE STRING    "The version of qcbor to use")
16
17# Entirely disable the floating-point support
18# in the qcbor library to reduce code size.
19set(QCBOR_OPT_DISABLE_FLOAT_HW_USE     ON  CACHE BOOL  "Eliminate dependency on FP hardware and FP instructions" FORCE)
20set(QCBOR_OPT_DISABLE_FLOAT_PREFERRED  ON  CACHE BOOL  "Eliminate support for half-precision and CBOR preferred serialization" FORCE)
21set(QCBOR_OPT_DISABLE_FLOAT_ALL        ON  CACHE BOOL  "Eliminate floating-point support completely" FORCE)
22
23fetch_remote_library(
24    LIB_NAME                qcbor
25    LIB_SOURCE_PATH_VAR     QCBOR_PATH
26    LIB_PATCH_DIR           ${CMAKE_CURRENT_LIST_DIR}
27    LIB_BASE_DIR            "${CMAKE_BINARY_DIR}/lib/ext"
28    FETCH_CONTENT_ARGS
29        GIT_REPOSITORY      https://github.com/laurencelundblade/QCBOR.git
30        GIT_TAG             ${QCBOR_VERSION}
31        GIT_PROGRESS        TRUE
32)
33
34add_subdirectory(${QCBOR_PATH} ${CMAKE_CURRENT_BINARY_DIR}/QCBOR)
35
36set_target_properties(qcbor PROPERTIES EXCLUDE_FROM_ALL TRUE)
37
38target_compile_options(qcbor
39    PUBLIC
40        ${COMPILER_CP_FLAG}
41)
42
43target_include_directories(qcbor
44    INTERFACE
45        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
46)
47