xmake.lua 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package("enoki")
  2. set_homepage("https://github.com/mitsuba-renderer/enoki")
  3. set_description("Enoki: structured vectorization and differentiation on modern processor architectures")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/mitsuba-renderer/enoki.git")
  6. add_versions("2024.04.19", "63a5f4c0a35a8513a39393a9ee92646ce44a386e")
  7. add_configs("shared", {description = "Build shared library", default = true, type = "boolean", readonly = true})
  8. add_configs("cuda", {description = "Build Enoki CUDA library", default = false, type = "boolean"})
  9. add_configs("cudacc", {description = "CUDA compute capability", default = "75", type = "string", values = {"35", "50", "52", "60", "61", "70", "75", "80", "86", "89", "90"}})
  10. add_configs("autodiff", {description = "Build Enoki automatic differentation library", default = false, type = "boolean"})
  11. add_configs("python", {description = "Build pybind11 interface to CUDA & automatic differentiation libraries", default = false, type = "boolean"})
  12. on_load(function (package)
  13. if package:config("cuda") then
  14. package:add("deps", "cuda")
  15. end
  16. if package:config("python") then
  17. package:add("deps", "python 3.x")
  18. end
  19. if package:config("cuda") or package:config("autodiff") then
  20. package:add("deps", "cmake")
  21. else
  22. package:set("kind", "library", {headeronly = true})
  23. end
  24. end)
  25. on_install("windows", "macosx", "linux", "mingw", function (package)
  26. os.cp("include/enoki", package:installdir("include"))
  27. if package:config("cuda") or package:config("autodiff") then
  28. local configs = {}
  29. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  30. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  31. table.insert(configs, "-DENOKI_CUDA=" .. (package:config("cuda") and "ON" or "OFF"))
  32. if package:config("cuda") then
  33. table.insert(configs, "-DENOKI_CUDA_COMPUTE_CAPABILITY=" .. package:config("cudacc"))
  34. end
  35. table.insert(configs, "-DENOKI_AUTODIFF=" .. (package:config("autodiff") and "ON" or "OFF"))
  36. table.insert(configs, "-DENOKI_PYTHON=" .. (package:config("python") and "ON" or "OFF"))
  37. import("package.tools.cmake").install(package, configs)
  38. end
  39. end)
  40. on_test(function (package)
  41. assert(package:check_cxxsnippets({test = [[
  42. #ifndef _USE_MATH_DEFINES
  43. #define _USE_MATH_DEFINES
  44. #endif
  45. #include <enoki/array.h>
  46. void test() {
  47. enoki::Array<int, 4> idx(1, 2, 3, 4);
  48. using MyFloat = enoki::Array<float, 4>;
  49. MyFloat a = enoki::zero<MyFloat>();
  50. }
  51. ]]}, {configs = {languages = "c++17"}}))
  52. end)