xmake.lua 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. package("faiss")
  2. set_homepage("https://github.com/facebookresearch/faiss/")
  3. set_description("A library for efficient similarity search and clustering of dense vectors.")
  4. set_license("MIT")
  5. add_urls("https://github.com/facebookresearch/faiss/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/facebookresearch/faiss.git")
  7. add_versions("v1.7.0", "f86d346ac9f409ee30abe37e52f6cce366b7f60d3924d65719f40aa07ceb4bec")
  8. add_deps("cmake")
  9. add_deps("cuda", {system = true, optional = true})
  10. add_deps("mkl", "cuda", {system = true, optional = true})
  11. if is_plat("linux") then
  12. add_syslinks("pthread")
  13. end
  14. on_load("windows|x64", "linux", function (package)
  15. if not find_package("mkl") then
  16. package:add("deps", "openblas")
  17. end
  18. end)
  19. on_install("windows|x64", "linux", function (package)
  20. io.replace("CMakeLists.txt", "add_subdirectory(demos)", "", {plain = true})
  21. io.replace("CMakeLists.txt", "add_subdirectory(tutorial/cpp)", "", {plain = true})
  22. local configs = {"-DFAISS_ENABLE_PYTHON=OFF", "-DBUILD_TESTING=OFF"}
  23. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  24. table.insert(configs, "-DFAISS_ENABLE_GPU=" .. (package:dep("cuda"):exists() and "ON" or "OFF"))
  25. import("package.tools.cmake").install(package, configs)
  26. end)
  27. on_test(function (package)
  28. assert(package:has_cxxtypes("faiss::MultiIndexQuantizer", {configs = {languages = "c++11"}, includes = "faiss/IndexPQ.h"}))
  29. end)