chore: switch to self-built flatbuffers (#2657)

* chore: switch to self-built flatbuffers

This should solve the linker errors on MacOs build.

---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2024-02-26 10:03:17 +02:00 committed by GitHub
parent 58f284c4f4
commit d54b600f31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 26 additions and 21 deletions

View file

@ -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
@ -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}/" )

View file

@ -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)

13
src/core/flatbuffers.h Normal file
View file

@ -0,0 +1,13 @@
// Copyright 2024, DragonflyDB authors. All rights reserved.
// See LICENSE for licensing terms.
//
#pragma once
#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>

View file

@ -2,10 +2,9 @@
// See LICENSE for licensing terms.
//
#include "core/flatbuffers.h"
#include <absl/strings/escaping.h>
#include <flatbuffers/flatbuffers.h>
#include <flatbuffers/flexbuffers.h>
#include <flatbuffers/idl.h>
#include "base/gtest.h"
#include "base/logging.h"

View file

@ -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)

View file

@ -7,8 +7,6 @@
#include <absl/strings/match.h>
#include <absl/strings/str_join.h>
#include <absl/strings/str_split.h>
#include <flatbuffers/flexbuffers.h>
#include <flatbuffers/idl.h>
#include <jsoncons/json.hpp>
#include <jsoncons_ext/jsonpatch/jsonpatch.hpp>
@ -17,6 +15,7 @@
#include "base/flags.h"
#include "base/logging.h"
#include "core/flatbuffers.h"
#include "core/json/json_object.h"
#include "core/json/path.h"
#include "facade/cmd_arg_parser.h"