Skip to content

Commit 667bb54

Browse files
committed
fix: add cmake subproject integration check
1 parent faadf62 commit 667bb54

3 files changed

Lines changed: 152 additions & 1 deletion

File tree

.github/workflows/03-macos-linux-build.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,35 @@ jobs:
107107
setuptools_scm
108108
shell: bash
109109

110+
- name: Check CMake subproject integration
111+
if: matrix.platform == 'linux-x64'
112+
run: |
113+
SMOKE_SOURCE="$RUNNER_TEMP/zvec-subproject-smoke"
114+
SMOKE_BUILD="$RUNNER_TEMP/zvec-subproject-build"
115+
116+
mkdir -p "$SMOKE_SOURCE" "$SMOKE_BUILD"
117+
cat > "$SMOKE_SOURCE/CMakeLists.txt" <<'EOF'
118+
cmake_minimum_required(VERSION 3.13)
119+
project(zvec_subproject_smoke LANGUAGES C CXX)
120+
121+
if(NOT ZVEC_SOURCE_DIR)
122+
message(FATAL_ERROR "ZVEC_SOURCE_DIR is required")
123+
endif()
124+
125+
add_subdirectory("${ZVEC_SOURCE_DIR}" zvec)
126+
EOF
127+
128+
cmake -S "$SMOKE_SOURCE" -B "$SMOKE_BUILD" -G Ninja \
129+
-DZVEC_SOURCE_DIR="$GITHUB_WORKSPACE" \
130+
-DCMAKE_BUILD_TYPE=Release \
131+
-DBUILD_TOOLS=OFF \
132+
-DBUILD_C_BINDINGS=OFF \
133+
-DBUILD_PYTHON_BINDINGS=OFF \
134+
-DENABLE_WERROR=ON \
135+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
136+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
137+
shell: bash
138+
110139
- name: Build from source
111140
run: |
112141
cd "$GITHUB_WORKSPACE"
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Nightly CMake Subproject Integration
2+
3+
on:
4+
schedule:
5+
# Run after the other nightly jobs to avoid starting every heavy job at once.
6+
- cron: '30 16 * * *'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
subproject-integration:
14+
name: Subproject Build & Example (linux-x64)
15+
runs-on: ubuntu-24.04
16+
timeout-minutes: 90
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v6
21+
with:
22+
ref: main
23+
submodules: recursive
24+
25+
- name: Setup ccache
26+
uses: hendrikmuhs/ccache-action@v1.2
27+
with:
28+
key: cmake-subproject-linux-x64
29+
max-size: 150M
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v6
33+
with:
34+
python-version: '3.10'
35+
cache: 'pip'
36+
cache-dependency-path: 'pyproject.toml'
37+
38+
- name: Install system dependencies
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get install -y --no-install-recommends \
42+
libaio-dev
43+
shell: bash
44+
45+
- name: Set up environment variables
46+
run: |
47+
NPROC=$(nproc 2>/dev/null || echo 2)
48+
echo "NPROC=$NPROC" >> "$GITHUB_ENV"
49+
echo "$(python -c 'import site; print(site.USER_BASE)')/bin" >> "$GITHUB_PATH"
50+
shell: bash
51+
52+
- name: Install dependencies
53+
run: |
54+
python -m pip install --upgrade pip
55+
python -m pip install \
56+
cmake==3.30.0 \
57+
ninja==1.11.1
58+
shell: bash
59+
60+
- name: Configure subproject integration
61+
run: |
62+
SMOKE_SOURCE="$RUNNER_TEMP/zvec-subproject-nightly"
63+
SMOKE_BUILD="$RUNNER_TEMP/zvec-subproject-nightly-build"
64+
65+
mkdir -p "$SMOKE_SOURCE" "$SMOKE_BUILD"
66+
cat > "$SMOKE_SOURCE/CMakeLists.txt" <<'EOF'
67+
cmake_minimum_required(VERSION 3.13)
68+
project(zvec_subproject_nightly LANGUAGES C CXX)
69+
set(CMAKE_CXX_STANDARD 17)
70+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
71+
72+
if(NOT ZVEC_SOURCE_DIR)
73+
message(FATAL_ERROR "ZVEC_SOURCE_DIR is required")
74+
endif()
75+
76+
add_subdirectory("${ZVEC_SOURCE_DIR}" zvec)
77+
78+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
79+
80+
add_executable(zvec_embed_db_example
81+
"${ZVEC_SOURCE_DIR}/examples/c++/db/main.cc")
82+
target_link_libraries(zvec_embed_db_example PRIVATE zvec_shared)
83+
84+
add_executable(zvec_embed_core_example
85+
"${ZVEC_SOURCE_DIR}/examples/c++/core/main.cc")
86+
target_link_libraries(zvec_embed_core_example PRIVATE zvec_shared)
87+
88+
add_executable(zvec_embed_ailego_example
89+
"${ZVEC_SOURCE_DIR}/examples/c++/ailego/main.cc")
90+
target_link_libraries(zvec_embed_ailego_example PRIVATE zvec_shared)
91+
EOF
92+
93+
cmake -S "$SMOKE_SOURCE" -B "$SMOKE_BUILD" -G Ninja \
94+
-DZVEC_SOURCE_DIR="$GITHUB_WORKSPACE" \
95+
-DCMAKE_BUILD_TYPE=Release \
96+
-DBUILD_TOOLS=OFF \
97+
-DBUILD_C_BINDINGS=OFF \
98+
-DBUILD_PYTHON_BINDINGS=OFF \
99+
-DENABLE_WERROR=ON \
100+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
101+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
102+
103+
echo "SMOKE_BUILD=$SMOKE_BUILD" >> "$GITHUB_ENV"
104+
shell: bash
105+
106+
- name: Build subproject targets
107+
run: |
108+
cmake --build "$SMOKE_BUILD" --target \
109+
core_knn_diskann \
110+
zvec_embed_db_example \
111+
zvec_embed_core_example \
112+
zvec_embed_ailego_example \
113+
--parallel "$NPROC"
114+
shell: bash
115+
116+
- name: Run subproject examples
117+
run: |
118+
cd "$SMOKE_BUILD"
119+
./bin/zvec_embed_db_example
120+
./bin/zvec_embed_core_example
121+
./bin/zvec_embed_ailego_example
122+
shell: bash

thirdparty/FastPFOR/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include(${CMAKE_SOURCE_DIR}/cmake/bazel.cmake)
1+
include(${PROJECT_ROOT_DIR}/cmake/bazel.cmake)
22

33
# On ARM platforms, FastPFOR uses SIMDe to emulate SSE intrinsics.
44
# Detection covers native ARM builds AND cross-compilation (e.g. iOS/Android).

0 commit comments

Comments
 (0)