mirror of
https://github.com/facebookresearch/faiss.git
synced 2025-06-03 21:54:02 +08:00
Summary: This diff is related to https://github.com/facebookresearch/faiss/issues/1722 File structure with `-DFAISS_ENABLE_GPU=OFF` ``` /usr/local/include/faiss/c_api ├── AutoTune_c.h ├── clone_index_c.h ├── Clustering_c.h ├── error_c.h ├── error_impl.h ├── faiss_c.h ├── impl │ └── AuxIndexStructures_c.h ├── Index_c.h ├── index_factory_c.h ├── IndexFlat_c.h ├── index_io_c.h ├── IndexIVF_c.h ├── IndexIVFFlat_c.h ├── IndexLSH_c.h ├── IndexPreTransform_c.h ├── IndexScalarQuantizer_c.h ├── IndexShards_c.h ├── macros_impl.h ├── MetaIndexes_c.h └── VectorTransform_c.h ``` File structure with `-DFAISS_ENABLE_GPU=ON` ``` /usr/local/include/faiss/c_api ├── AutoTune_c.h ├── clone_index_c.h ├── Clustering_c.h ├── error_c.h ├── error_impl.h ├── faiss_c.h ├── gpu │ ├── DeviceUtils_c.h │ ├── GpuAutoTune_c.h │ ├── GpuClonerOptions_c.h │ ├── GpuIndex_c.h │ ├── GpuIndicesOptions_c.h │ ├── GpuResources_c.h │ ├── macros_impl.h │ └── StandardGpuResources_c.h ├── impl │ └── AuxIndexStructures_c.h ├── Index_c.h ├── index_factory_c.h ├── IndexFlat_c.h ├── index_io_c.h ├── IndexIVF_c.h ├── IndexIVFFlat_c.h ├── IndexLSH_c.h ├── IndexPreTransform_c.h ├── IndexScalarQuantizer_c.h ├── IndexShards_c.h ├── macros_impl.h ├── MetaIndexes_c.h └── VectorTransform_c.h ``` Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1841 Reviewed By: mdouze Differential Revision: D27992822 Pulled By: beauby fbshipit-source-id: 63fa9a39c77502d138453cb4b04c50652e732196
56 lines
1.3 KiB
CMake
56 lines
1.3 KiB
CMake
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This source code is licensed under the MIT license found in the
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
cmake_minimum_required(VERSION 3.17 FATAL_ERROR)
|
|
|
|
project(faiss_c_library LANGUAGES C CXX)
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
|
|
set(FAISS_C_SRC
|
|
AutoTune_c.cpp
|
|
Clustering_c.cpp
|
|
IndexFlat_c.cpp
|
|
IndexIVFFlat_c.cpp
|
|
IndexIVF_c.cpp
|
|
IndexLSH_c.cpp
|
|
IndexPreTransform_c.cpp
|
|
VectorTransform_c.cpp
|
|
IndexShards_c.cpp
|
|
Index_c.cpp
|
|
IndexScalarQuantizer_c.cpp
|
|
MetaIndexes_c.cpp
|
|
clone_index_c.cpp
|
|
error_impl.cpp
|
|
index_factory_c.cpp
|
|
index_io_c.cpp
|
|
impl/AuxIndexStructures_c.cpp
|
|
)
|
|
add_library(faiss_c ${FAISS_C_SRC})
|
|
target_link_libraries(faiss_c PRIVATE faiss)
|
|
|
|
function(faiss_install_headers headers p)
|
|
foreach(h ${headers})
|
|
get_filename_component(f ${h} DIRECTORY)
|
|
install(FILES ${h}
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/faiss/${p}/${f}
|
|
)
|
|
endforeach()
|
|
endfunction()
|
|
|
|
file(GLOB FAISS_C_API_HEADERS
|
|
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
|
"*.h"
|
|
"impl/*.h")
|
|
|
|
faiss_install_headers("${FAISS_C_API_HEADERS}" c_api)
|
|
|
|
add_executable(example_c EXCLUDE_FROM_ALL example_c.c)
|
|
target_link_libraries(example_c PRIVATE faiss_c)
|
|
|
|
if(FAISS_ENABLE_GPU)
|
|
add_subdirectory(gpu)
|
|
endif()
|