Skip to content

Commit f7fa31d

Browse files
authored
Expose CPPSTD configuration (#507)
Signed-off-by: yhmo <yihua.mo@zilliz.com>
1 parent 54fc6a7 commit f7fa31d

6 files changed

Lines changed: 17 additions & 16 deletions

File tree

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ project(milvus_sdk LANGUAGES CXX)
2020
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
2121
set(CMAKE_VERBOSE_MAKEFILE OFF)
2222
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
23-
set(CMAKE_CXX_STANDARD 14)
23+
set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard used to build Milvus C++ SDK")
2424
set(CMAKE_CXX_STANDARD_REQUIRED ON)
25+
if (NOT CMAKE_CXX_STANDARD MATCHES "^[0-9]+$")
26+
message(FATAL_ERROR "CMAKE_CXX_STANDARD must be a numeric C++ standard value, such as 14, 17, or 20")
27+
endif()
28+
if (CMAKE_CXX_STANDARD LESS 14)
29+
message(FATAL_ERROR "milvus-sdk-cpp requires C++14 or newer (got CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD})")
30+
endif()
2531

2632
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2733
set(BUILD_SCRIPTS_DIR ${PROJECT_SOURCE_DIR}/scripts)

conanfile.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ def validate(self):
6565
# The project currently builds with C++14.
6666
check_min_cppstd(self, 14)
6767

68-
def configure(self):
69-
# Ensure dependency graph variants match the project's C++ standard.
70-
# (Without this, Conan may resolve packages for gnu17 and then fail to
71-
# find compatible binaries.)
72-
self.settings.compiler.cppstd = "14"
73-
7468
def generate(self):
7569
tc = CMakeToolchain(self)
7670

examples/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
cmake_minimum_required(VERSION 3.5)
1818
project(milvus_sdk_example LANGUAGES CXX C)
1919

20-
set(CMAKE_CXX_STANDARD 11)
21-
set(CMAKE_CXX_STANDARD_REQUIRED on)
22-
2320
message(STATUS " CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
2421
include_directories(${CMAKE_SOURCE_DIR}/src/include)
2522

scripts/build.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ DO_INSTALL="OFF"
3030
CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-/usr/local}
3131
BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS:-ON}
3232
BUILD_FROM_CONAN="ON"
33-
33+
CPPSTD=${CPPSTD:-14}
34+
if [[ ! "${CPPSTD}" =~ ^[0-9]+$ ]]; then
35+
echo "ERROR! CPPSTD must be a numeric C++ standard value, such as 14, 17, or 20"
36+
exit 1
37+
fi
3438

3539
JOBS="${JOBS:-$(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || echo 3)}"
3640
if [ ${JOBS} -lt 3 ] ; then
@@ -133,7 +137,6 @@ if [[ "${BUILD_FROM_CONAN}" == "ON" ]]; then
133137
# Dependencies must come from Conan; external gRPC is not supported.
134138
# Users can override the Conan executable via CONAN.
135139
CONAN=${CONAN:-conan}
136-
CPPSTD=${CPPSTD:-14}
137140
CONAN_LIBCXX_SETTINGS=()
138141
if [[ -n "${CONAN_LIBCXX:-}" ]]; then
139142
CONAN_LIBCXX_SETTINGS+=("-s" "compiler.libcxx=${CONAN_LIBCXX}")
@@ -229,6 +232,7 @@ esac
229232
CMAKE_CMD="cmake \
230233
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} \
231234
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
235+
-DCMAKE_CXX_STANDARD=${CPPSTD} \
232236
-DMILVUS_BUILD_TEST=${BUILD_TEST} \
233237
-DMILVUS_BUILD_COVERAGE=${BUILD_COVERAGE} \
234238
-DMILVUS_BUILD_EXAMPLES=${CMAKE_BUILD_EXAMPLES} \

src/impl/MilvusClientV2Impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,8 +849,8 @@ MilvusClientV2Impl::LoadPartitions(const LoadPartitionsRequest& request) {
849849
auto db_name = connection_.CurrentDbName(request.DatabaseName());
850850
uint32_t loading_progress = 0;
851851
uint32_t refresh_progress = 0;
852-
auto status = connection_.GetLoadingProgress(db_name, request.CollectionName(), request.PartitionNames(),
853-
loading_progress, refresh_progress);
852+
auto status = connection_.GetLoadingProgress(
853+
db_name, request.CollectionName(), request.PartitionNames(), loading_progress, refresh_progress);
854854
if (!status.IsOk()) {
855855
return status;
856856
}

src/impl/utils/ConnectionHandler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ class ConnectionHandler {
6565
// This interface is not exposed to users
6666
Status
6767
GetLoadingProgress(const std::string& db_name, const std::string& collection_name,
68-
const std::set<std::string>& partition_names, uint32_t& progress,
69-
uint32_t& refresh_progress, uint64_t rpc_timeout_ms = 0);
68+
const std::set<std::string>& partition_names, uint32_t& progress, uint32_t& refresh_progress,
69+
uint64_t rpc_timeout_ms = 0);
7070

7171
/**
7272
* Internal wait for status query done.

0 commit comments

Comments
 (0)