enhance: modify bson thirdparty lib compile mode (#45406)

#42533

Signed-off-by: luzhang <luzhang@zilliz.com>
Co-authored-by: luzhang <luzhang@zilliz.com>
This commit is contained in:
zhagnlu 2025-12-30 15:41:21 +08:00 committed by GitHub
parent b18ebd9468
commit 83ab90af93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 67 additions and 3 deletions

View File

@ -43,7 +43,6 @@ class MilvusConan(ConanFile):
"simde/0.8.2#5e1edfd5cba92f25d79bf6ef4616b972",
"xxhash/0.8.3#199e63ab9800302c232d030b27accec0",
"unordered_dense/4.4.0#6a855c992618cc4c63019109a2e47298",
"mongo-cxx-driver/3.11.0#ae206de0e90fb8cb2fb95465fb8b2f01",
"geos/3.12.0#0b177c90c25a8ca210578fb9e2899c37",
"icu/74.2#cd1937b9561b8950a2ae6311284c5813",
"libavrocpp/1.12.1@milvus/dev",

View File

@ -32,6 +32,7 @@ include_directories(
${KNOWHERE_INCLUDE_DIR}
${SIMDJSON_INCLUDE_DIR}
${TANTIVY_INCLUDE_DIR}
${BSONCXX_INCLUDE_DIR}
${CONAN_INCLUDE_DIRS}
${MILVUS_COMMON_INCLUDE_DIR}
${MILVUS_STORAGE_INCLUDE_DIR}
@ -71,13 +72,14 @@ add_library(milvus_core SHARED
$<TARGET_OBJECTS:milvus_rescores>
)
set(LINK_TARGETS
set(LINK_TARGETS
boost_bitset_ext
simdjson
tantivy_binding
knowhere
milvus-storage
milvus-common
bsoncxx
${OpenMP_CXX_FLAGS}
${CONAN_LIBS}
)

View File

@ -28,7 +28,6 @@
#include <bsoncxx/json.hpp>
#include <simdjson.h>
#include <bsoncxx/types.hpp>
#include <bson/bson.h>
#include "index/json_stats/utils.h"
#include "common/EasyAssert.h"
namespace milvus::index {

View File

@ -37,6 +37,7 @@ add_subdirectory(boost_ext)
add_subdirectory(rocksdb)
add_subdirectory(rdkafka)
add_subdirectory(simdjson)
add_subdirectory(bsoncxx)
if (USE_OPENDAL)
add_subdirectory(opendal)
endif()

View File

@ -0,0 +1,63 @@
#-------------------------------------------------------------------------------
# Copyright (C) 2019-2020 Zilliz. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under the License.
#-------------------------------------------------------------------------------
message(STATUS "Building mongo-cxx-driver (bsoncxx only) from source")
# Disable tests and examples for mongo-cxx-driver
set(ENABLE_TESTS OFF CACHE INTERNAL "")
set(BUILD_TESTING OFF CACHE INTERNAL "")
set(ENABLE_EXAMPLES OFF CACHE INTERNAL "")
set(BUILD_MONGOCXX OFF CACHE INTERNAL "")
set(BUILD_SHARED_LIBS ON CACHE INTERNAL "")
set(BUILD_VERSION "0.0.0" CACHE INTERNAL "")
# Disable optional features in mongo-c-driver to avoid linking issues on macOS
set(ENABLE_SASL OFF CACHE INTERNAL "")
set(ENABLE_SNAPPY OFF CACHE INTERNAL "")
set(ENABLE_ZSTD OFF CACHE INTERNAL "")
set(ENABLE_SSL OFF CACHE INTERNAL "")
# Use FetchContent to download and build mongo-cxx-driver at configure time
FetchContent_Declare(
mongo-cxx-driver
GIT_REPOSITORY https://github.com/mongodb/mongo-cxx-driver.git
GIT_TAG releases/v3.11
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(mongo-cxx-driver)
# The targets are now available: bsoncxx_shared
# Create aliases for easier use
if(TARGET bsoncxx_shared)
add_library(bsoncxx ALIAS bsoncxx_shared)
message(STATUS "bsoncxx target created as alias to bsoncxx_shared")
endif()
# Get source directories from FetchContent
FetchContent_GetProperties(mongo-cxx-driver SOURCE_DIR MONGO_CXX_SOURCE_DIR)
# Set the include directories for use by other CMakeLists that use include_directories()
# We need:
# - v_noabi directory for the main headers
# - base include for v1 headers
# - build/lib for generated config headers
set(BSONCXX_INCLUDE_DIR
"${MONGO_CXX_SOURCE_DIR}/src/bsoncxx/include/bsoncxx/v_noabi"
"${MONGO_CXX_SOURCE_DIR}/src/bsoncxx/include"
"${CMAKE_BINARY_DIR}/3rdparty_download/mongo-cxx-driver-build/src/bsoncxx/lib/bsoncxx/v_noabi"
"${CMAKE_BINARY_DIR}/3rdparty_download/mongo-c-driver-src/src/libbson/src/bson"
"${CMAKE_BINARY_DIR}/3rdparty_download/mongo-c-driver-build/src/libbson/src/bson"
CACHE INTERNAL "Path to bsoncxx include directories")
message("BSONCXX_INCLUDE_DIR: ${BSONCXX_INCLUDE_DIR}")