Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ if(SVS_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

if(SVS_BUILD_CPP_RUNTIME_BINDINGS)
add_subdirectory(bindings/cpp)
endif()

# The benchmark directory contains a sub-component that is used by both the benchmarking
# framework and the unit-tests.
#
Expand Down
49 changes: 37 additions & 12 deletions bindings/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ if (SVS_RUNTIME_ENABLE_LVQ_LEANVEC)
svs_compile_options
svs_x86_options_base
)
elseif(TARGET svs::svs)
message(FATAL_ERROR
"Pre-built LVQ/LeanVec SVS library cannot be used in SVS main build. "
"Please build SVS Runtime using bindins/cpp directory as CMake source root."
)
else()
# Links to LTO-enabled static library, requires GCC/G++ 11.2
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11.2" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11.3")
Expand All @@ -111,17 +106,47 @@ if (SVS_RUNTIME_ENABLE_LVQ_LEANVEC)
"Pre-built LVQ/LeanVec SVS library requires GCC/G++ v.11.2 to apply LTO optimizations."
"Current compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}"
)
set(SVS_URL "https://github.com/intel/ScalableVectorSearch/releases/download/v1.0.0-dev/svs-shared-library-1.0.0-dev-NIGHTLY-20251119.tar.gz")
set(SVS_URL "file:///home/eglaser/rafik_split/rafik_submodule/shared_only/shared.tar.gz")
endif()
include(FetchContent)
FetchContent_Declare(
svs
svs_tarball
URL ${SVS_URL}
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
FetchContent_MakeAvailable(svs)
list(APPEND CMAKE_PREFIX_PATH "${svs_SOURCE_DIR}")
find_package(svs REQUIRED)
FetchContent_MakeAvailable(svs_tarball)

if(TARGET svs::svs)
# Building from public root while fetching tarball leads to multiple svs::svs targets
# Requires manual import of the static library
message(STATUS "Root build detected: Manually importing static library from prebuilt package.")

find_library(SVS_STATIC_LIB_PATH
NAMES svs_static_library
PATHS "${svs_tarball_SOURCE_DIR}/lib" "${svs_tarball_SOURCE_DIR}/lib64"
NO_DEFAULT_PATH
)

if(NOT SVS_STATIC_LIB_PATH)
message(FATAL_ERROR "Could not find svs_static_library in ${svs_tarball_SOURCE_DIR}")
endif()

add_library(svs::svs_static_library STATIC IMPORTED)
set_target_properties(svs::svs_static_library PROPERTIES
IMPORTED_LOCATION "${SVS_STATIC_LIB_PATH}"
INTERFACE_INCLUDE_DIRECTORIES "${svs_tarball_SOURCE_DIR}/include"
)

# Alias local compile options if available
if(TARGET svs_compile_options AND NOT TARGET svs::svs_compile_options)
add_library(svs::svs_compile_options ALIAS svs_compile_options)
endif()
else()
# Prepend to CMAKE_PREFIX_PATH to ensure we find the downloaded package
# instead of a system/conda installed one, which might lack the static library.
list(INSERT CMAKE_PREFIX_PATH 0 "${svs_tarball_SOURCE_DIR}")
find_package(svs REQUIRED)
endif()

target_link_libraries(${TARGET_NAME} PRIVATE
svs::svs
svs::svs_compile_options
Expand Down Expand Up @@ -194,6 +219,6 @@ install(FILES
)

# Build tests if requested
if(SVS_BUILD_RUNTIME_TESTS)
if(SVS_BUILD_TESTS)
add_subdirectory(tests)
endif()
5 changes: 5 additions & 0 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ option(SVS_BUILD_EXAMPLES
OFF # disabled by default
)

option(SVS_BUILD_CPP_RUNTIME_BINDINGS
"Build the C++ runtime bindings library."
OFF # disabled by default
)

option(SVS_BUILD_BENCHMARK
"Build the benchmark executable."
OFF # disabled by default
Expand Down
2 changes: 1 addition & 1 deletion docker/x86_64/build-cpp-runtime-bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mkdir -p /workspace/bindings/cpp/build_cpp_bindings /workspace/install_cpp_bindi

# Build and install runtime bindings library
cd /workspace/bindings/cpp/build_cpp_bindings
CC=gcc CXX=g++ cmake .. -DSVS_BUILD_RUNTIME_TESTS=ON -DCMAKE_INSTALL_PREFIX=/workspace/install_cpp_bindings -DCMAKE_INSTALL_LIBDIR=lib
CC=gcc CXX=g++ cmake .. -DSVS_BUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=/workspace/install_cpp_bindings -DCMAKE_INSTALL_LIBDIR=lib
cmake --build . -j
cmake --install .

Expand Down
Loading