Skip to content

Commit

Permalink
Update QCBOR from 1.1 to 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Maffre committed Sep 1, 2023
1 parent a49343a commit f616612
Show file tree
Hide file tree
Showing 21 changed files with 1,877 additions and 767 deletions.
86 changes: 72 additions & 14 deletions 3rdparty/exported/QCBOR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,77 @@
cmake_minimum_required(VERSION 3.10.2)
#-------------------------------------------------------------------------------
# Copyright (c) 2022-2023, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
# See BSD-3-Clause license in README.md
#-------------------------------------------------------------------------------

cmake_minimum_required(VERSION 3.15)

project(qcbor
DESCRIPTION "QCBOR"
LANGUAGES C
VERSION 1.0.0)
DESCRIPTION "QCBOR"
LANGUAGES C
VERSION 1.1.0
)

set(BUILD_QCBOR_TEST "OFF" CACHE STRING "Build QCBOR test suite [OFF, LIB, APP]")
set(BUILD_QCBOR_WARN OFF CACHE BOOL "Compile with the warning flags used in the QCBOR release process")
# BUILD_SHARED_LIBS is a built-in global CMake flag
# The shared library is not made by default because of platform
# variability For example MacOS and Linux behave differently and some
# IoT OS's don't support them at all.
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries instead of static ones")

# Configuration:
# Floating-point support (see README.md for more information)
set(QCBOR_OPT_DISABLE_FLOAT_HW_USE OFF CACHE BOOL "Eliminate dependency on FP hardware and FP instructions")
set(QCBOR_OPT_DISABLE_FLOAT_PREFERRED OFF CACHE BOOL "Eliminate support for half-precision and CBOR preferred serialization")
set(QCBOR_OPT_DISABLE_FLOAT_ALL OFF CACHE BOOL "Eliminate floating-point support completely")

if (BUILD_QCBOR_WARN)
# Compile options applying to all targets in current directory and below
add_compile_options(-Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wcast-qual)
endif()

add_library(qcbor)

target_sources(qcbor
PRIVATE
src/ieee754.c
src/qcbor_decode.c
src/qcbor_encode.c
src/qcbor_err_to_str.c
src/UsefulBuf.c
)

target_include_directories(qcbor
PUBLIC
inc
PRIVATE
src
)

set(CMAKE_C_FLAGS "-pedantic -Wall -O3 -ffunction-sections")
target_compile_definitions(qcbor
PRIVATE
$<$<BOOL:${QCBOR_OPT_DISABLE_FLOAT_HW_USE}>:QCBOR_DISABLE_FLOAT_HW_USE>
$<$<BOOL:${QCBOR_OPT_DISABLE_FLOAT_PREFERRED}>:QCBOR_DISABLE_PREFERRED_FLOAT>
$<$<BOOL:${QCBOR_OPT_DISABLE_FLOAT_ALL}>:USEFULBUF_DISABLE_ALL_FLOAT>
)

set(SOURCE
src/ieee754.c
src/qcbor_decode.c
src/qcbor_encode.c
src/qcbor_err_to_str.c
src/UsefulBuf.c
)
if (BUILD_SHARED_LIBS)
target_compile_options(qcbor PRIVATE -Os -fPIC)
endif()

add_library(qcbor ${SOURCE})
# The math library is needed for floating-point support.
# To avoid need for it #define QCBOR_DISABLE_FLOAT_HW_USE
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
# Using GCC
target_link_libraries(qcbor
PRIVATE
$<$<NOT:$<BOOL:${QCBOR_OPT_DISABLE_FLOAT_HW_USE}>>:m>
)
endif()

target_include_directories(qcbor PUBLIC inc)
if (NOT BUILD_QCBOR_TEST STREQUAL "OFF")
add_subdirectory(test)
endif()
11 changes: 8 additions & 3 deletions 3rdparty/exported/QCBOR/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ LIBS=-lm
# The $(CMD_LINE) variable allows passing in extra flags. This is
# used on the stringent build script that is in
# https://github.com/laurencelundblade/qdv. This script is used
# before pushes to master (though not yet through and automated build
# process)
# before pushes to master (though not yet through an automated build
# process). See "warn:" below.
CFLAGS=$(CMD_LINE) -I inc -I test -Os -fPIC


Expand All @@ -30,7 +30,7 @@ TEST_OBJ=test/UsefulBuf_Tests.o test/qcbor_encode_tests.o \
test/qcbor_decode_tests.o test/run_tests.o \
test/float_tests.o test/half_to_double_from_rfc7049.o example.o ub-example.o

.PHONY: all so install uninstall clean
.PHONY: all so install uninstall clean warn

all: qcbortest libqcbor.a

Expand All @@ -42,6 +42,11 @@ qcbortest: libqcbor.a $(TEST_OBJ) cmd_line_main.o
libqcbor.a: $(QCBOR_OBJ)
ar -r $@ $^

# run "make warn" as a handy way to compile with the warning flags
# used in the QCBOR release process. See CFLAGS above.
warn:
make CMD_LINE="-Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wcast-qual"


# The shared library is not made by default because of platform
# variability For example MacOS and Linux behave differently and some
Expand Down
Loading

0 comments on commit f616612

Please sign in to comment.