Skip to content

Commit

Permalink
chore: switch to self-built flatbuffers
Browse files Browse the repository at this point in the history
This should solve the linker errors on MacOs build.

Signed-off-by: Roman Gershman <[email protected]>
  • Loading branch information
romange committed Feb 25, 2024
1 parent 050649d commit e843ec1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
22 changes: 8 additions & 14 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ add_third_party(
LIB "none"
)

add_third_party(
flatbuffers
URL https://github.com/google/flatbuffers/archive/refs/tags/v23.5.26.tar.gz
CMAKE_PASS_FLAGS "-DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_LIBCXX_WITH_CLANG=OFF
-DFLATBUFFERS_BUILD_FLATC=OFF"
)


add_library(TRDP::jsoncons INTERFACE IMPORTED)
add_dependencies(TRDP::jsoncons jsoncons_project)
set_target_properties(TRDP::jsoncons PROPERTIES
Expand All @@ -141,20 +149,6 @@ set_target_properties(TRDP::fast_float PROPERTIES

Message(STATUS "THIRD_PARTY_LIB_DIR ${THIRD_PARTY_LIB_DIR}")

find_package(Flatbuffers)
if (TARGET flatbuffers::flatbuffers)
get_target_property(FLATBUF_PATH flatbuffers::flatbuffers LOCATION)
set(FLATBUF_TARGET flatbuffers::flatbuffers)
Message("-- Flatbuffers found at ${FLATBUF_PATH}")
elseif (TARGET flatbuffers::flatbuffers_shared)
# alpine linux has shared library
get_target_property(FLATBUF_PATH flatbuffers::flatbuffers_shared LOCATION)
set(FLATBUF_TARGET flatbuffers::flatbuffers_shared)
Message("-- Flatbuffers found at ${FLATBUF_PATH}")
else()
Message("-- Flatbuffers not found, please install via libflatbuffers-dev")
endif()

option(ENABLE_GIT_VERSION "Build with Git metadata" OFF)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/" )
Expand Down
2 changes: 1 addition & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ cxx_test(string_map_test dfly_core LABELS DFLY)
cxx_test(sorted_map_test dfly_core redis_test_lib LABELS DFLY)
cxx_test(bptree_set_test dfly_core LABELS DFLY)
cxx_test(score_map_test dfly_core LABELS DFLY)
cxx_test(flatbuffers_test dfly_core ${FLATBUF_TARGET} LABELS DFLY)
cxx_test(flatbuffers_test dfly_core TRDP::flatbuffers LABELS DFLY)
5 changes: 5 additions & 0 deletions src/core/flatbuffers_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
//

#include <absl/strings/escaping.h>

#ifndef __USE_GNU // needed to flatbuffers to compile with musl libc.
#define FLATBUFFERS_LOCALE_INDEPENDENT 0
#endif

#include <flatbuffers/flatbuffers.h>
#include <flatbuffers/flexbuffers.h>
#include <flatbuffers/idl.h>
Expand Down
2 changes: 1 addition & 1 deletion src/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ cxx_link(dfly_transaction dfly_core strings_lib TRDP::fast_float)
cxx_link(dragonfly_lib dfly_transaction dfly_facade redis_lib awsv2_lib jsonpath
strings_lib html_lib
http_client_lib absl::random_random TRDP::jsoncons ${ZSTD_LIB} TRDP::lz4
TRDP::croncpp ${FLATBUF_TARGET})
TRDP::croncpp TRDP::flatbuffers)

if (DF_USE_SSL)
set(TLS_LIB tls_lib)
Expand Down
5 changes: 5 additions & 0 deletions src/server/json_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#include <absl/strings/match.h>
#include <absl/strings/str_join.h>
#include <absl/strings/str_split.h>

#ifndef __USE_GNU // needed to flatbuffers to compile with musl libc.
#define FLATBUFFERS_LOCALE_INDEPENDENT 0
#endif

#include <flatbuffers/flexbuffers.h>
#include <flatbuffers/idl.h>

Expand Down

0 comments on commit e843ec1

Please sign in to comment.