Skip to content

Commit b7e89ec

Browse files
committed
Fix build errors when WIRH_CARDINAL=true
Signed-off-by: yhmo <yihua.mo@zilliz.com>
1 parent 9a3f6d1 commit b7e89ec

6 files changed

Lines changed: 40 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,11 @@ set(CARDINAL_LIBS "")
179179

180180
if(WITH_CARDINAL)
181181
add_definitions(-DKNOWHERE_WITH_CARDINAL)
182+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
183+
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/conan-compat-modules")
184+
endif()
182185
add_subdirectory(cmake/libs/cardinal/v1)
186+
target_link_libraries(cardinalv1 PRIVATE milvus-common::milvus-common)
183187
list(APPEND CARDINAL_LIBS cardinalv1)
184188
add_subdirectory(cmake/libs/cardinal/v2)
185189
list(APPEND CARDINAL_LIBS cardinalv2)

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ WITH_BENCHMARK ?=
2727
WITH_ASAN ?=
2828
WITH_SVS ?=
2929
WITH_CARDINAL ?=
30+
CARDINAL_VERSION_FORCE_CHECKOUT ?=
3031
WITH_DEBUG ?=
3132
CONAN_PROFILE ?=
3233

@@ -35,7 +36,7 @@ CONAN_PROFILE ?=
3536
# variables such as WITH_ASAN to every sub-process, which causes the custom
3637
# folly recipe to pick up $ENV{WITH_ASAN} and compile folly itself with
3738
# -fsanitize=address — breaking the build on GCC.
38-
unexport WITH_GPU WITH_UT WITH_BENCHMARK WITH_ASAN WITH_CARDINAL WITH_DEBUG
39+
unexport WITH_GPU WITH_UT WITH_BENCHMARK WITH_ASAN WITH_CARDINAL CARDINAL_VERSION_FORCE_CHECKOUT WITH_DEBUG
3940

4041
# ---------- Derived settings ----------
4142
ifdef WITH_DEBUG
@@ -92,6 +93,16 @@ ifdef WITH_CARDINAL
9293
CONAN_SETTINGS += -o \&:with_cardinal=True
9394
endif
9495

96+
ifneq ($(CARDINAL_VERSION_FORCE_CHECKOUT),)
97+
ifneq ($(filter True true ON on 1,$(CARDINAL_VERSION_FORCE_CHECKOUT)),)
98+
CONAN_SETTINGS += -o \&:cardinal_version_force_checkout=True
99+
else ifneq ($(filter False false OFF off 0,$(CARDINAL_VERSION_FORCE_CHECKOUT)),)
100+
CONAN_SETTINGS += -o \&:cardinal_version_force_checkout=False
101+
else
102+
$(error CARDINAL_VERSION_FORCE_CHECKOUT must be True/False, ON/OFF, or 1/0)
103+
endif
104+
endif
105+
95106
ifdef CONAN_PROFILE
96107
CONAN_SETTINGS += -pr $(CONAN_PROFILE)
97108
endif
@@ -160,6 +171,7 @@ help: ## Show available targets
160171
@echo " WITH_ASAN=True Enable AddressSanitizer"
161172
@echo " WITH_SVS=True Enable SVS (Intel Scalable Vector Search, x86 only)"
162173
@echo " WITH_CARDINAL=True Enable Cardinal build"
174+
@echo " CARDINAL_VERSION_FORCE_CHECKOUT=True Force Cardinal checkout to configured version"
163175
@echo " WITH_DEBUG=True Debug build (default: Release)"
164176
@echo " CONAN_PROFILE=<p> Use a custom Conan profile (e.g. clang, gcc-15)"
165177
@echo " LIBCXX=<lib> Override compiler.libcxx (auto-detected from OS)"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
find_package(OpenBLAS CONFIG REQUIRED)
2+
3+
set(BLAS_FOUND TRUE)
4+
set(BLAS_LIBRARIES OpenBLAS::OpenBLAS)
5+
set(BLAS_INCLUDE_DIRS "")
6+
7+
if(NOT TARGET BLAS::BLAS)
8+
add_library(BLAS::BLAS INTERFACE IMPORTED)
9+
target_link_libraries(BLAS::BLAS INTERFACE OpenBLAS::OpenBLAS)
10+
endif()

cmake/libs/cardinal/v2/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ project(knowhere CXX C)
33

44
# Use short SHA1 as version
55
# v2.6 tag is used for cardinal v2
6-
set(CARDINAL_VERSION v3.0.1)
6+
# now we use recipe branch of cardinal repo since the pr is not merged into cardinal repo: https://github.com/zilliztech/cardinal/pull/834
7+
# the cardinal repo fetches knowhere to run ci workflow so the two repos are coupling. to decouple them:
8+
# 1. use cardinal recipe branch in knowhere to pass the ci check
9+
# 2. in the cardianl pr#834, use the knowhere branch to run ci
10+
# 3. merge the knowhere pr
11+
# 4. in the cardinal pr#834, use the knowhere master branch to run ci, and merge the cardinal pr after ci passed
12+
set(CARDINAL_VERSION recipe)
713
set(CARDINAL_REPO_URL "https://github.com/zilliztech/cardinal.git")
814

915
set(CARDINAL_ROOT "${KNOWHERE_THRID_ROOT}/cardinalv2")

conanfile.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class KnowhereConan(ConanFile):
2828
"with_diskann": [True, False],
2929
"with_svs": [True, False],
3030
"with_cardinal": [True, False],
31+
"cardinal_version_force_checkout": [True, False],
3132
"with_profiler": [True, False],
3233
"with_ut": [True, False],
3334
"with_benchmark": [True, False],
@@ -44,6 +45,7 @@ class KnowhereConan(ConanFile):
4445
"with_diskann": False,
4546
"with_svs": False,
4647
"with_cardinal": False,
48+
"cardinal_version_force_checkout": False,
4749
"with_profiler": False,
4850
"with_ut": False,
4951
"glog/*:shared": True,
@@ -210,6 +212,7 @@ def generate(self):
210212
tc.variables["WITH_DISKANN"] = self.options.with_diskann
211213
tc.variables["WITH_SVS"] = self.options.with_svs
212214
tc.variables["WITH_CARDINAL"] = self.options.with_cardinal
215+
tc.variables["CARDINAL_VERSION_FORCE_CHECKOUT"] = self.options.cardinal_version_force_checkout
213216
tc.variables["WITH_CUVS"] = self.options.with_cuvs
214217
tc.variables["WITH_PROFILER"] = self.options.with_profiler
215218
tc.variables["WITH_UT"] = self.options.with_ut

scripts/install_deps.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ if [[ "${OS}" == "Linux" ]]; then
5353
packages=(
5454
g++ gcc make cmake ccache
5555
libaio-dev # DiskANN async I/O
56+
libopenblas-dev # Linux Cardinal v1 uses CMake FindBLAS; macOS uses Apple BLAS.
5657
libcurl4-openssl-dev # folly dependency
5758
libdouble-conversion-dev # folly dependency
5859
libevent-dev # gRPC dependency
@@ -75,6 +76,7 @@ if [[ "${OS}" == "Linux" ]]; then
7576
packages=(
7677
gcc-c++ gcc make cmake ccache
7778
libaio-devel # DiskANN async I/O
79+
openblas-devel # Linux Cardinal v1 uses CMake FindBLAS; macOS uses Apple BLAS.
7880
libcurl-devel # folly dependency
7981
double-conversion-devel # folly dependency
8082
libevent-devel # gRPC dependency
@@ -98,6 +100,7 @@ if [[ "${OS}" == "Linux" ]]; then
98100

99101
elif [[ "${OS}" == "Mac" ]]; then
100102
brew install libomp llvm ninja ccache cmake
103+
# OpenBLAS is intentionally not installed: Cardinal v1/v2 use Apple BLAS.
101104
# libomp: OpenMP parallelization
102105
# llvm: clang toolchain
103106
# ninja: fast build system

0 commit comments

Comments
 (0)