CMakeLists.txt 5.4 KB
Newer Older
C
Cai Yudong 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
#-------------------------------------------------------------------------------
# Copyright (C) 2019-2020 Zilliz. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under the License.
#-------------------------------------------------------------------------------

S
starlord 已提交
14 15
include_directories(${INDEX_SOURCE_DIR}/knowhere)
include_directories(${INDEX_SOURCE_DIR}/thirdparty)
C
Cai Yudong 已提交
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

if (MILVUS_SUPPORT_SPTAG)
    include_directories(${INDEX_SOURCE_DIR}/thirdparty/SPTAG/AnnService)

    set(SPTAG_SOURCE_DIR ${INDEX_SOURCE_DIR}/thirdparty/SPTAG)
    file(GLOB HDR_FILES
            ${SPTAG_SOURCE_DIR}/AnnService/inc/Core/*.h
            ${SPTAG_SOURCE_DIR}/AnnService/inc/Core/Common/*.h
            ${SPTAG_SOURCE_DIR}/AnnService/inc/Core/BKT/*.h
            ${SPTAG_SOURCE_DIR}/AnnService/inc/Core/KDT/*.h
            ${SPTAG_SOURCE_DIR}/AnnService/inc/Helper/*.h)
    file(GLOB SRC_FILES
            ${SPTAG_SOURCE_DIR}/AnnService/src/Core/*.cpp
            ${SPTAG_SOURCE_DIR}/AnnService/src/Core/Common/*.cpp
            ${SPTAG_SOURCE_DIR}/AnnService/src/Core/BKT/*.cpp
            ${SPTAG_SOURCE_DIR}/AnnService/src/Core/KDT/*.cpp
            ${SPTAG_SOURCE_DIR}/AnnService/src/Helper/*.cpp)

    if (NOT TARGET SPTAGLibStatic)
        add_library(SPTAGLibStatic STATIC ${SRC_FILES} ${HDR_FILES})
    endif ()
Y
youny626 已提交
37
endif ()
X
xj.lin 已提交
38 39

set(external_srcs
X
xiaojun.lin 已提交
40
        knowhere/common/Exception.cpp
C
Cai Yudong 已提交
41
        knowhere/common/Log.cpp
X
xiaojun.lin 已提交
42
        knowhere/common/Timer.cpp
X
xj.lin 已提交
43 44 45
        )

set(index_srcs
C
Cai Yudong 已提交
46 47 48 49 50 51 52 53 54
        knowhere/index/vector_index/adapter/VectorAdapter.cpp
        knowhere/index/vector_index/helpers/FaissIO.cpp
        knowhere/index/vector_index/helpers/IndexParameter.cpp
        knowhere/index/vector_index/impl/nsg/Distance.cpp
        knowhere/index/vector_index/impl/nsg/NSG.cpp
        knowhere/index/vector_index/impl/nsg/NSGHelper.cpp
        knowhere/index/vector_index/impl/nsg/NSGIO.cpp
        knowhere/index/vector_index/ConfAdapter.cpp
        knowhere/index/vector_index/ConfAdapterMgr.cpp
G
groot 已提交
55
        knowhere/index/vector_index/FaissBaseBinaryIndex.cpp
C
Cai Yudong 已提交
56
        knowhere/index/vector_index/FaissBaseIndex.cpp
G
groot 已提交
57
        knowhere/index/vector_index/IndexBinaryIDMAP.cpp
C
Cai Yudong 已提交
58
        knowhere/index/vector_index/IndexBinaryIVF.cpp
T
Tinkerrr 已提交
59
        knowhere/index/vector_index/IndexHNSW.cpp
C
Cai Yudong 已提交
60 61
        knowhere/index/vector_index/IndexIDMAP.cpp
        knowhere/index/vector_index/IndexIVF.cpp
X
xiaojun.lin 已提交
62
        knowhere/index/vector_index/IndexIVFPQ.cpp
C
Cai Yudong 已提交
63 64 65 66
        knowhere/index/vector_index/IndexIVFSQ.cpp
        knowhere/index/vector_index/IndexNSG.cpp
        knowhere/index/vector_index/IndexType.cpp
        knowhere/index/vector_index/VecIndexFactory.cpp
O
op-hunter 已提交
67
        knowhere/index/vector_index/IndexAnnoy.cpp
X
xj.lin 已提交
68 69
        )

C
Cai Yudong 已提交
70 71 72 73 74 75 76 77 78
if (MILVUS_SUPPORT_SPTAG)
    set(index_srcs
            knowhere/index/vector_index/adapter/SptagAdapter.cpp
            knowhere/index/vector_index/helpers/SPTAGParameterMgr.cpp
            knowhere/index/vector_index/IndexSPTAG.cpp
            ${index_srcs}
            )
endif ()

X
xj.lin 已提交
79 80 81 82 83 84
set(depend_libs
        faiss
        gomp
        gfortran
        pthread
        )
C
Cai Yudong 已提交
85 86 87 88 89 90 91 92 93

if (MILVUS_SUPPORT_SPTAG)
    set(depend_libs
            SPTAGLibStatic
            ${depend_libs}
            )
endif ()


Z
Zhiru Zhu 已提交
94
if (FAISS_WITH_MKL)
Y
youny626 已提交
95 96 97 98 99 100 101 102 103
    set(depend_libs ${depend_libs}
            "-Wl,--start-group \
            ${MKL_LIB_PATH}/libmkl_intel_ilp64.a \
            ${MKL_LIB_PATH}/libmkl_gnu_thread.a \
            ${MKL_LIB_PATH}/libmkl_core.a \
            -Wl,--end-group -lgomp -lpthread -lm -ldl"
            )
else ()
    set(depend_libs ${depend_libs}
O
op-hunter 已提交
104
            ${OpenBLAS_LIBRARIES}
105 106
            ${LAPACK_LIBRARIES}
            )
Y
youny626 已提交
107 108
endif ()

C
Cai Yudong 已提交
109
if (MILVUS_GPU_VERSION)
Y
youny626 已提交
110 111 112 113 114 115 116 117 118 119 120
    include_directories(${CUDA_INCLUDE_DIRS})
    link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64")
    set(cuda_lib
            cudart
            cublas
            )
    set(depend_libs ${depend_libs}
            ${cuda_lib}
            )

    set(index_srcs ${index_srcs}
C
Cai Yudong 已提交
121 122 123 124 125
            knowhere/index/vector_index/gpu/IndexGPUIDMAP.cpp
            knowhere/index/vector_index/gpu/IndexGPUIVF.cpp
            knowhere/index/vector_index/gpu/IndexGPUIVFPQ.cpp
            knowhere/index/vector_index/gpu/IndexGPUIVFSQ.cpp
            knowhere/index/vector_index/gpu/IndexIVFSQHybrid.cpp
Y
youny626 已提交
126 127 128 129
            knowhere/index/vector_index/helpers/Cloner.cpp
            knowhere/index/vector_index/helpers/FaissGpuResourceMgr.cpp
            )
endif ()
X
xj.lin 已提交
130

Y
youny626 已提交
131
if (NOT TARGET knowhere)
Z
zhiru 已提交
132 133 134 135 136
    add_library(
            knowhere STATIC
            ${external_srcs}
            ${index_srcs}
    )
Y
youny626 已提交
137
endif ()
X
xj.lin 已提交
138 139 140 141 142 143

target_link_libraries(
        knowhere
        ${depend_libs}
)

S
starlord 已提交
144 145 146
set(INDEX_INCLUDE_DIRS
        ${INDEX_SOURCE_DIR}/knowhere
        ${INDEX_SOURCE_DIR}/thirdparty
Z
zhiru 已提交
147
        ${FAISS_INCLUDE_DIR}
O
op-hunter 已提交
148
        ${OpenBLAS_INCLUDE_DIR}
Z
zhiru 已提交
149 150 151
        ${LAPACK_INCLUDE_DIR}
        )

C
Cai Yudong 已提交
152 153 154 155 156 157 158
if (MILVUS_SUPPORT_SPTAG)
    set(INDEX_INCLUDE_DIRS
            ${INDEX_SOURCE_DIR}/thirdparty/SPTAG/AnnService
            ${INDEX_INCLUDE_DIRS}
        )
endif ()

159
set(INDEX_INCLUDE_DIRS ${INDEX_INCLUDE_DIRS} PARENT_SCOPE)