Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
65 lines (53 loc) · 2.21 KB
/
Copy pathCMakeLists.txt
File metadata and controls
65 lines (53 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
cmake_minimum_required(VERSION 3.20)
project(wintergreen VERSION 0.1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(WINTERGREEN_BUILD_PYTHON "Build the optional pybind11 module" ON)
option(WINTERGREEN_BUILD_TESTS "Build C++ tests" ON)
option(WINTERGREEN_BUILD_BENCHMARKS "Build the microbenchmark executable" ON)
add_library(wintergreen_core
src/distance.cpp
src/flat.cpp
src/hnsw.cpp
src/ivf.cpp
src/kmeans.cpp
src/pq.cpp
src/topk.cpp
src/vector_ops.cpp
)
target_include_directories(wintergreen_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
if(MSVC)
target_compile_options(wintergreen_core PRIVATE /W4 /permissive-)
else()
target_compile_options(wintergreen_core PRIVATE -Wall -Wextra -Wpedantic)
endif()
if(WINTERGREEN_BUILD_PYTHON)
find_package(Python COMPONENTS Interpreter Development REQUIRED)
find_package(pybind11 CONFIG REQUIRED)
pybind11_add_module(wintergreen_python bindings/python.cpp)
target_link_libraries(wintergreen_python PRIVATE wintergreen_core)
target_include_directories(wintergreen_python PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
set_target_properties(wintergreen_python PROPERTIES OUTPUT_NAME wintergreen)
target_compile_definitions(wintergreen_python PRIVATE
WINTERGREEN_VERSION="${PROJECT_VERSION}")
endif()
if(WINTERGREEN_BUILD_TESTS)
enable_testing()
function(wintergreen_add_test target source)
add_executable(${target} ${source})
target_link_libraries(${target} PRIVATE wintergreen_core)
add_test(NAME ${target} COMMAND ${target})
endfunction()
wintergreen_add_test(test_distance tests/test_distance.cpp)
wintergreen_add_test(test_flat tests/test_flat.cpp)
wintergreen_add_test(test_hnsw tests/test_hnsw.cpp)
wintergreen_add_test(test_ivf tests/test_ivf.cpp)
wintergreen_add_test(test_kmeans tests/test_kmeans.cpp)
wintergreen_add_test(test_pq tests/test_pq.cpp)
wintergreen_add_test(test_topk tests/test_topk.cpp)
endif()
if(WINTERGREEN_BUILD_BENCHMARKS)
add_executable(wintergreen_benchmark benchmarks/benchmark.cpp)
target_link_libraries(wintergreen_benchmark PRIVATE wintergreen_core)
endif()