diff --git a/packages/f/faiss/xmake.lua b/packages/f/faiss/xmake.lua index 6c52132efb3..2471e42327a 100644 --- a/packages/f/faiss/xmake.lua +++ b/packages/f/faiss/xmake.lua @@ -1,5 +1,4 @@ package("faiss") - set_homepage("https://github.com/facebookresearch/faiss/") set_description("A library for efficient similarity search and clustering of dense vectors.") set_license("MIT") @@ -7,28 +6,47 @@ package("faiss") add_urls("https://github.com/facebookresearch/faiss/archive/refs/tags/$(version).tar.gz", "https://github.com/facebookresearch/faiss.git") add_versions("v1.7.0", "f86d346ac9f409ee30abe37e52f6cce366b7f60d3924d65719f40aa07ceb4bec") + add_versions("v1.12.0", "561376d1a44771bf1230fabeef9c81643468009b45a585382cf38d3a7a94990a") + + add_configs("gpu", {description = "Enable support for GPU indexes.", default = false, type = "boolean"}) + add_configs("gpu_static", {description = "Link GPU libraries statically.", default = false, type = "boolean"}) + add_configs("mkl", {description = "Enable MKL.", default = false, type = "boolean"}) + add_configs("python", {description = "Build Python extension.", default = false, type = "boolean"}) + add_configs("c_api", {description = "Build C API.", default = false, type = "boolean"}) + add_configs("lto", {description = "Enable Link-Time optimization.", default = false, type = "boolean"}) - add_deps("cmake") - add_deps("cuda", {system = true, optional = true}) - add_deps("mkl", "cuda", {system = true, optional = true}) if is_plat("linux") then add_syslinks("pthread") end - on_load("windows|x64", "linux", function (package) - if not find_package("mkl") then + + add_deps("cmake", "openmp") + on_load(function (package) + if package:config("gpu") then + package:add("deps", "cuda") + end + if package:config("mkl") then + package:add("deps", "mkl", {system = true, optional = true}) + else package:add("deps", "openblas") end end) - on_install("windows|x64", "linux", function (package) - io.replace("CMakeLists.txt", "add_subdirectory(demos)", "", {plain = true}) - io.replace("CMakeLists.txt", "add_subdirectory(tutorial/cpp)", "", {plain = true}) - local configs = {"-DFAISS_ENABLE_PYTHON=OFF", "-DBUILD_TESTING=OFF"} - table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) - table.insert(configs, "-DFAISS_ENABLE_GPU=" .. (package:dep("cuda"):exists() and "ON" or "OFF")) + on_install("windows|x64", "linux", "macosx", function (package) + local configs = { + "-DBUILD_TESTING=OFF", + "-DFAISS_ENABLE_EXTRAS=OFF", + } + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) + table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) + table.insert(configs, "-DFAISS_ENABLE_GPU=" .. (package:config("gpu") and "ON" or "OFF")) + table.insert(configs, "-DFAISS_GPU_STATIC=" .. (package:config("gpu_static") and "ON" or "OFF")) + table.insert(configs, "-DFAISS_ENABLE_MKL=" .. (package:config("mkl") and "ON" or "OFF")) + table.insert(configs, "-DFAISS_ENABLE_PYTHON=" .. (package:config("python") and "ON" or "OFF")) + table.insert(configs, "-DFAISS_ENABLE_C_API=" .. (package:config("c_api") and "ON" or "OFF")) + table.insert(configs, "-DFAISS_ENABLE_LTO=" .. (package:config("lto") and "ON" or "OFF")) import("package.tools.cmake").install(package, configs) end) on_test(function (package) - assert(package:has_cxxtypes("faiss::MultiIndexQuantizer", {configs = {languages = "c++11"}, includes = "faiss/IndexPQ.h"})) + assert(package:has_cxxtypes("faiss::MultiIndexQuantizer", {configs = {languages = "c++17"}, includes = "faiss/IndexPQ.h"})) end)