diff --git a/internal/core/conanfile.py b/internal/core/conanfile.py index 275b987470..37eb2e9141 100644 --- a/internal/core/conanfile.py +++ b/internal/core/conanfile.py @@ -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", diff --git a/internal/core/src/CMakeLists.txt b/internal/core/src/CMakeLists.txt index 9bc17eefda..17d66f77a4 100644 --- a/internal/core/src/CMakeLists.txt +++ b/internal/core/src/CMakeLists.txt @@ -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 $ ) -set(LINK_TARGETS +set(LINK_TARGETS boost_bitset_ext simdjson tantivy_binding knowhere milvus-storage milvus-common + bsoncxx ${OpenMP_CXX_FLAGS} ${CONAN_LIBS} ) diff --git a/internal/core/src/index/json_stats/bson_builder.h b/internal/core/src/index/json_stats/bson_builder.h index 327e5ea3c9..c772d3c700 100644 --- a/internal/core/src/index/json_stats/bson_builder.h +++ b/internal/core/src/index/json_stats/bson_builder.h @@ -28,7 +28,6 @@ #include #include #include -#include #include "index/json_stats/utils.h" #include "common/EasyAssert.h" namespace milvus::index { diff --git a/internal/core/thirdparty/CMakeLists.txt b/internal/core/thirdparty/CMakeLists.txt index 5f14072cc3..526fcb02d3 100644 --- a/internal/core/thirdparty/CMakeLists.txt +++ b/internal/core/thirdparty/CMakeLists.txt @@ -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() diff --git a/internal/core/thirdparty/bsoncxx/CMakeLists.txt b/internal/core/thirdparty/bsoncxx/CMakeLists.txt new file mode 100644 index 0000000000..e66d9e83db --- /dev/null +++ b/internal/core/thirdparty/bsoncxx/CMakeLists.txt @@ -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}")