esp-idf/components/cbor/CMakeLists.txt
Ivan Grokhotkov 1e2b1238c6 cbor: add a workaround for -ffreestanding being passed to clang
Toolchain CMake files for clang currently pass -ffreestanding option
to prevent clang from picking the wrong copy of stdint.h. This is a
temporary hack until we fix clang distributions to not include the
GCC version of stdint.h. This hack, however, results in setting
__STDC_HOSTED__=0, which is being checked by cbor header files,
making some required functions unavailable as a result.
Undefine __STDC_HOSTED__ as a workaround. This flag is only passed
when compiling cbor itself.
2021-09-16 11:07:54 +02:00

21 lines
1.0 KiB
CMake

idf_component_register(SRCS "tinycbor/src/cborencoder_close_container_checked.c"
"tinycbor/src/cborencoder.c"
"tinycbor/src/cborerrorstrings.c"
"tinycbor/src/cborparser_dup_string.c"
"tinycbor/src/cborparser.c"
"tinycbor/src/cborpretty_stdio.c"
"tinycbor/src/cborpretty.c"
"tinycbor/src/cbortojson.c"
"tinycbor/src/cborvalidation.c"
"tinycbor/src/open_memstream.c"
INCLUDE_DIRS "port/include"
PRIV_INCLUDE_DIRS "tinycbor/src")
# for open_memstream.c
set_source_files_properties(tinycbor/src/open_memstream.c PROPERTIES COMPILE_DEFINITIONS "__linux__")
# workaround for the fact that we are passing -ffreestanding to Clang
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
target_compile_options(${COMPONENT_LIB} PRIVATE "-U __STDC_HOSTED__")
endif()