From 702fe90d5a7f3f39d22fafcf803394ab15ae60cb Mon Sep 17 00:00:00 2001 From: "xufeihong.xfh" Date: Fri, 5 Jun 2026 16:56:27 +0800 Subject: [PATCH] fix: add cmake subproject integration check --- .github/workflows/03-macos-linux-build.yml | 29 +++++++++++++++++++++ src/core/algorithm/diskann/CMakeLists.txt | 4 +-- tests/core/algorithm/diskann/CMakeLists.txt | 6 ++--- thirdparty/FastPFOR/CMakeLists.txt | 2 +- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/.github/workflows/03-macos-linux-build.yml b/.github/workflows/03-macos-linux-build.yml index f9fdd8f16..f4c18752a 100644 --- a/.github/workflows/03-macos-linux-build.yml +++ b/.github/workflows/03-macos-linux-build.yml @@ -107,6 +107,35 @@ jobs: setuptools_scm shell: bash + - name: Check CMake subproject integration + if: matrix.platform == 'linux-x64' + run: | + SMOKE_SOURCE="$RUNNER_TEMP/zvec-subproject-smoke" + SMOKE_BUILD="$RUNNER_TEMP/zvec-subproject-build" + + mkdir -p "$SMOKE_SOURCE" "$SMOKE_BUILD" + cat > "$SMOKE_SOURCE/CMakeLists.txt" <<'EOF' + cmake_minimum_required(VERSION 3.13) + project(zvec_subproject_smoke LANGUAGES C CXX) + + if(NOT ZVEC_SOURCE_DIR) + message(FATAL_ERROR "ZVEC_SOURCE_DIR is required") + endif() + + add_subdirectory("${ZVEC_SOURCE_DIR}" zvec) + EOF + + cmake -S "$SMOKE_SOURCE" -B "$SMOKE_BUILD" -G Ninja \ + -DZVEC_SOURCE_DIR="$GITHUB_WORKSPACE" \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_TOOLS=OFF \ + -DBUILD_C_BINDINGS=OFF \ + -DBUILD_PYTHON_BINDINGS=OFF \ + -DENABLE_WERROR=ON \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + shell: bash + - name: Build from source run: | cd "$GITHUB_WORKSPACE" diff --git a/src/core/algorithm/diskann/CMakeLists.txt b/src/core/algorithm/diskann/CMakeLists.txt index 443be55ec..d29f05076 100644 --- a/src/core/algorithm/diskann/CMakeLists.txt +++ b/src/core/algorithm/diskann/CMakeLists.txt @@ -1,4 +1,4 @@ -include(${CMAKE_SOURCE_DIR}/cmake/bazel.cmake) +include(${PROJECT_ROOT_DIR}/cmake/bazel.cmake) file(GLOB_RECURSE ALL_SRCS *.cc *.c) @@ -54,4 +54,4 @@ endif() # as an optional plugin that users load at runtime via zvec::LoadDiskAnnPlugin(). set_target_properties(core_knn_diskann PROPERTIES OUTPUT_NAME zvec_diskann_plugin -) \ No newline at end of file +) diff --git a/tests/core/algorithm/diskann/CMakeLists.txt b/tests/core/algorithm/diskann/CMakeLists.txt index 86d3848c8..e8228f3ac 100644 --- a/tests/core/algorithm/diskann/CMakeLists.txt +++ b/tests/core/algorithm/diskann/CMakeLists.txt @@ -1,4 +1,4 @@ -include(${CMAKE_SOURCE_DIR}/cmake/bazel.cmake) +include(${PROJECT_ROOT_DIR}/cmake/bazel.cmake) file(GLOB_RECURSE ALL_TEST_SRCS *_test.cc) @@ -9,6 +9,6 @@ foreach(CC_SRCS ${ALL_TEST_SRCS}) STRICT LIBS zvec_ailego core_framework core_utility core_metric core_quantizer core_knn_cluster core_plugin core_knn_diskann SRCS ${CC_SRCS} - INCS . ${CMAKE_SOURCE_DIR}/src/core ${CMAKE_SOURCE_DIR}/src/core/algorithm/diskann + INCS . ${PROJECT_ROOT_DIR}/src/core ${PROJECT_ROOT_DIR}/src/core/algorithm/diskann ) -endforeach() \ No newline at end of file +endforeach() diff --git a/thirdparty/FastPFOR/CMakeLists.txt b/thirdparty/FastPFOR/CMakeLists.txt index 77a8dfba9..813ee6c2d 100644 --- a/thirdparty/FastPFOR/CMakeLists.txt +++ b/thirdparty/FastPFOR/CMakeLists.txt @@ -1,4 +1,4 @@ -include(${CMAKE_SOURCE_DIR}/cmake/bazel.cmake) +include(${PROJECT_ROOT_DIR}/cmake/bazel.cmake) # On ARM platforms, FastPFOR uses SIMDe to emulate SSE intrinsics. # Detection covers native ARM builds AND cross-compilation (e.g. iOS/Android).