xmake.lua 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package("open3d")
  2. set_homepage("http://www.open3d.org/")
  3. set_description("Open3D: A Modern Library for 3D Data Processing")
  4. set_license("MIT")
  5. add_urls("https://github.com/isl-org/Open3D/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/isl-org/Open3D.git")
  7. add_versions("v0.15.1", "4bcfbaa6fcbcc14fba46a4d719b9256fffac09b23f8344a7d561b26394159660")
  8. add_configs("python", {description = "Build the python module.", default = false, type = "boolean"})
  9. add_configs("cuda", {description = "Enable CUDA support.", default = false, type = "boolean"})
  10. add_configs("blas", {description = "Choose BLAS vendor.", default = "mkl", type = "string", values = {"mkl", "openblas"}})
  11. add_deps("cmake", "nasm")
  12. add_includedirs("include", "include/open3d/3rdparty")
  13. if is_plat("linux") then
  14. add_deps("libx11", "libxrandr", "libxrender", "libxinerama", "libxcursor", "libxfixes", "libxext", "libxi")
  15. end
  16. on_load("windows|x64", "linux|x86_64", "macosx|x86_64", function (package)
  17. if package:config("cuda") then
  18. package:add("deps", "cuda")
  19. end
  20. if package:config("python") then
  21. package:add("deps", "python 3.x")
  22. else
  23. package:add("deps", "python 3.x", {kind = "binary"})
  24. end
  25. if package:config("blas") ~= "mkl" then
  26. package:add("deps", package:config("blas"))
  27. end
  28. end)
  29. on_install("windows|x64", "linux|x86_64", "macosx|x86_64", function (package)
  30. if package:is_plat("linux") then
  31. if package:has_tool("cxx", "clang", "clangxx") then
  32. package:add("syslinks", "stdc++fs")
  33. package:add("ldflags", "-fsanitize=safe-stack")
  34. else
  35. raise("GCC compiler is not supported yet, please use LLVM and Clang instead.")
  36. end
  37. end
  38. io.replace("CMakeLists.txt", "add_subdirectory(docs)", "", {plain = true})
  39. io.replace("CMakeLists.txt", "add_subdirectory(examples)", "", {plain = true})
  40. io.writefile("examples/test_data/download_file_list.json", "{}")
  41. if package:is_plat("windows") then
  42. local vs = import("core.tool.toolchain").load("msvc"):config("vs")
  43. local vstool
  44. if vs == "2015" then vstool = "vc140"
  45. elseif vs == "2017" then vstool = "vc141"
  46. elseif vs == "2019" then vstool = "vc142"
  47. elseif vs == "2022" then vstool = "vc143"
  48. end
  49. assert(vstool, "unknown vs version: %s", vs)
  50. io.replace("3rdparty/assimp/assimp.cmake", "lib_name assimp%-vc.-%-mt", format("lib_name assimp-%s-mt", vstool))
  51. end
  52. local configs = {"-DCMAKE_INSTALL_LIBDIR=lib",
  53. "-DCMAKE_FIND_FRAMEWORK=LAST",
  54. "-DBUILD_EXAMPLES=OFF",
  55. "-DBUILD_UNIT_TESTS=OFF",
  56. "-DBUILD_BENCHMARKS=OFF",
  57. "-DBUILD_ISPC_MODULE=OFF",
  58. "-DBUILD_WEBRTC=OFF",
  59. "-DUSE_SYSTEM_BLAS=ON",
  60. "-DBUILD_FILAMENT_FROM_SOURCE=OFF",
  61. "-DWITH_IPPICV=OFF",
  62. "-DPREFER_OSX_HOMEBREW=OFF",
  63. "-DDEVELOPER_BUILD=OFF"}
  64. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  65. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  66. table.insert(configs, "-DBUILD_PYTHON_MODULE=" .. (package:config("python") and "ON" or "OFF"))
  67. table.insert(configs, "-DBUILD_CUDA_MODULE=" .. (package:config("cuda") and "ON" or "OFF"))
  68. if package:is_plat("windows") then
  69. table.insert(configs, "-DSTATIC_WINDOWS_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  70. end
  71. table.insert(configs, "-DUSE_BLAS=" .. (package:config("blas") == "openblas" and "ON" or "OFF"))
  72. if package:is_plat("windows") then
  73. import("package.tools.cmake").install(package, configs, {buildir = os.tmpfile() .. ".dir"})
  74. elseif package:is_plat("linux") then
  75. import("package.tools.cmake").install(package, configs, {packagedeps = {"libxrandr", "libxrender", "libxinerama", "libxcursor", "libxfixes", "libxext", "libxi", "libx11"}})
  76. else
  77. import("package.tools.cmake").install(package, configs)
  78. end
  79. if not package:is_plat("windows") then
  80. package:add("links", "Open3D")
  81. for _, f in ipairs(os.files(path.join(package:installdir("lib"), "lib*.a"))) do
  82. if f:match(".+Open3D_3rdparty_.+%.a") then
  83. package:add("links", path.basename(f):match("lib(.+)"))
  84. end
  85. end
  86. end
  87. end)
  88. on_test(function (package)
  89. assert(package:check_cxxsnippets({test = [[
  90. #include <vector>
  91. #include <string>
  92. void test() {
  93. using namespace open3d::utility::filesystem;
  94. std::vector<std::string> filenames;
  95. ListFilesInDirectory(".", filenames);
  96. }
  97. ]]}, {configs = {languages = "c++14"}, includes = "open3d/Open3D.h"}))
  98. end)