Skip to content

Commit 5e63a35

Browse files
committed
Fix tinycbor include directory
When tinycbor is provided by an external build system (such as required when git submodules are not supported), the tinycbor headers are placed in a 'tinycbor/' directory: | #include <tinycbor/cbor.h> We need to adjust the cbor sources for this directory, which means our internal dependency needs to be built slightly differently. We copy the headers to a folder in the build directory, and point the top-level CMake to this folder. Fixes build error: | In file included from cbor_decode_stream.cpp:6: | cbor_decode_stream.hpp:13:10: fatal error: cbor.h: No such file or directory | #include <cbor.h> | ^~~~~~~~
1 parent aeea659 commit 5e63a35

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ include_directories(
113113
SYSTEM
114114
# system includes
115115
deps/outcome
116-
deps/tinycbor/src
116+
${TINY_CBOR_INCLUDE_DIRS}
117117
)
118118

119119
add_subdirectory(core)

core/codec/cbor/cbor_decode_stream.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
#include <vector>
1212

13-
#include <cbor.h>
1413
#include <gsl/span>
14+
#include <tinycbor/cbor.h>
1515

1616
namespace fc::codec::cbor {
1717
/** Decodes CBOR */

core/codec/cbor/cbor_encode_stream.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <array>
1212
#include <vector>
1313

14-
#include <cbor.h>
14+
#include <tinycbor/cbor.h>
1515

1616
#include "common/enum.hpp"
1717

deps/tinycbor.cmake

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,20 @@ add_library(tinycbor
1414
tinycbor/src/cborvalidation.c
1515
)
1616
disable_clang_tidy(tinycbor)
17+
18+
# Copy headers for core code to imitate install step
19+
set(TINY_CBOR_HEADERS
20+
cbor.h
21+
tinycbor-version.h
22+
)
23+
foreach(header ${TINY_CBOR_HEADERS})
24+
configure_file(tinycbor/src/${header}
25+
include/tinycbor/${header}
26+
COPYONLY
27+
)
28+
endforeach()
29+
30+
set(TINY_CBOR_INCLUDE_DIRS
31+
${CMAKE_BINARY_DIR}/deps/include
32+
PARENT_SCOPE
33+
)

0 commit comments

Comments
 (0)