1# 2# SPDX-License-Identifier: BSD-3-Clause 3# SPDX-FileCopyrightText: Copyright TF-RMM Contributors. 4# 5 6add_subdirectory("ext/qcbor") 7 8# 9# Set up qcbor using our own libc. This is done by getting certain properties 10# from our libc target and applying them to qcbor - not ideal, but qcbor 11# doesn't provide an interface library for us to use. 12# 13get_target_property(system_includes rmm-lib-libc 14 INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) 15get_target_property(includes rmm-lib-libc 16 INTERFACE_INCLUDE_DIRECTORIES) 17get_target_property(definitions rmm-lib-libc 18 INTERFACE_COMPILE_DEFINITIONS) 19get_target_property(options rmm-lib-libc 20 INTERFACE_COMPILE_OPTIONS) 21 22# 23# System include directories appear in both the `SYSTEM_INCLUDE_DIRECTORIES` and 24# `INCLUDE_DIRECTORIES` properties, so filter them out of the latter. 25# 26list(REMOVE_ITEM includes ${system_includes}) 27 28# 29# Target properties that are not set return `<PROPERTY>-NOTFOUND`. Clear any 30# variables where this occurred. 31# 32foreach(set IN ITEMS system_includes includes definitions options) 33 if(NOT ${set}) 34 set(${set}) 35 endif() 36endforeach() 37 38# QCBOR custom definitions 39list(APPEND definitions "QCBOR_DISABLE_FLOAT_HW_USE") 40list(APPEND definitions "USEFULBUF_DISABLE_ALL_FLOAT") 41 42# 43# Create compiler flags from the libc properties we retrieved. 44# 45list(TRANSFORM definitions PREPEND " -D") 46 47foreach(set IN ITEMS options definitions) 48 string(REPLACE ";" " " ${set} "${${set}}") 49endforeach() 50 51string(PREPEND qcbor_C_FLAGS "${definitions} ") 52# Add the relevant build flags. TODO: Currently CBOR is only passed Release build flag 53string(PREPEND qcbor_C_FLAGS "${options} ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE} ") 54string(PREPEND qcbor_C_FLAGS "-Wno-maybe-uninitialized ") 55 56string(REPLACE " " ";" qcbor_C_FLAGS ${qcbor_C_FLAGS}) 57 58# 59# qcbor's build system ignores and overwrites the flags we specify in our 60# toolchain files. Un-overwrite them, because they're there for a good reason. 61# 62target_include_directories(qcbor 63 PUBLIC "${RMM_SOURCE_DIR}/ext/qcbor/inc" 64) 65 66target_include_directories(qcbor 67 PRIVATE 68 ${includes} 69 ${system_includes} 70) 71 72target_compile_options(qcbor 73 PRIVATE 74 ${qcbor_C_FLAGS} 75) 76 77target_link_libraries(qcbor 78 PRIVATE 79 rmm-lib-libc 80) 81 82link_libraries(qcbor) 83