fix: misc fix for Windows(BUILD_SHARED_LIBS, CI) (#296)

This commit is contained in:
Jalin Wang
2026-04-02 09:23:35 +08:00
committed by GitHub
parent 7af6a31ae8
commit ca4b893755
18 changed files with 127 additions and 45 deletions
+20 -4
View File
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.26)
cmake_policy(SET CMP0077 NEW)
project(zvec-example-c++)
set(CMAKE_CXX_STANDARD 17)
@@ -20,14 +20,31 @@ set(ZVEC_DEPENDENCY_LIB_DIR ${CMAKE_BINARY_DIR}/../../../${HOST_BUILD_DIR}/exter
include_directories(${ZVEC_INCLUDE_DIR})
link_directories(${ZVEC_LIB_DIR} ${ZVEC_DEPENDENCY_LIB_DIR})
# Support multi-config builds (libs in Release/ or Debug/ subdirectories)
if (CMAKE_BUILD_TYPE)
link_directories(
${ZVEC_LIB_DIR}/${CMAKE_BUILD_TYPE}
${ZVEC_DEPENDENCY_LIB_DIR}/${CMAKE_BUILD_TYPE}
)
endif ()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# --- Determine debug/release library names ---
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(GLOG_LIB glogd)
set(GFLAGS_LIB gflags_nothreads_debug)
if (WIN32)
set(GFLAGS_LIB gflags_nothreads_static_debug)
else ()
set(GFLAGS_LIB gflags_nothreads_debug)
endif ()
set(PROTOBUF_LIB protobufd)
else()
set(GLOG_LIB glog)
set(GFLAGS_LIB gflags_nothreads)
if (WIN32)
set(GFLAGS_LIB gflags_nothreads_static)
else ()
set(GFLAGS_LIB gflags_nothreads)
endif ()
set(PROTOBUF_LIB protobuf)
endif()
@@ -48,7 +65,6 @@ if (NOT WIN32)
${CMAKE_DL_LIBS}
)
set(zvec_db_deps
roaring
rocksdb
+2 -3
View File
@@ -1,4 +1,5 @@
#include <cstdlib>
#include <filesystem>
#include <iostream>
#include <zvec/core/interface/index.h>
#include <zvec/core/interface/index_factory.h>
@@ -46,9 +47,7 @@ Index::Pointer create_index(const BaseIndexParam::Pointer &param,
}
int main() {
char cmd_buf[100];
snprintf(cmd_buf, 100, "rm -f %s", index_name.c_str());
system(cmd_buf);
std::filesystem::remove(index_name);
auto param = HNSWIndexParamBuilder()
.WithMetricType(MetricType::kInnerProduct)
+2 -2
View File
@@ -1,4 +1,5 @@
#include <cstdlib>
#include <filesystem>
#include <string>
#include <vector>
#include <zvec/db/collection.h>
@@ -188,8 +189,7 @@ CollectionSchema::Ptr create_schema() {
int main() {
std::string path = "./demo";
std::string rm_cmd = "rm -rf " + path;
system(rm_cmd.c_str());
std::filesystem::remove_all(path);
auto schema = create_schema();
CollectionOptions options{false, true};