From c8b5b4560a1442cf06a0d837073768df2a46c095 Mon Sep 17 00:00:00 2001 From: Hoildkv <42310255+xq114@users.noreply.github.com> Date: Tue, 22 Mar 2022 20:05:11 +0800 Subject: [PATCH] add open3d (#1065) * add open3d * use stdc++fs in favor of c++experimental * add filament 1.9 * improve open3d --- packages/f/filament/xmake.lua | 3 + packages/o/open3d/xmake.lua | 104 ++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 packages/o/open3d/xmake.lua diff --git a/packages/f/filament/xmake.lua b/packages/f/filament/xmake.lua index 50577cc7a..66eda5800 100644 --- a/packages/f/filament/xmake.lua +++ b/packages/f/filament/xmake.lua @@ -6,12 +6,15 @@ package("filament") if is_plat("windows") and is_arch("x64") then add_urls("https://github.com/google/filament/releases/download/v$(version)/filament-v$(version)-windows.tgz") + add_versions("1.9.23", "8f5728dd944c052f991bfb15d18cd6fc8f678d0cbd37bb066d76bf682ab789c8") add_versions("1.20.3", "0a3fdd5fe8662a02117f3de51dcbea3b260cff716a7cffa407ca939727d7b634") elseif is_plat("macosx") and is_arch("x86_64") then add_urls("https://github.com/google/filament/releases/download/v$(version)/filament-v$(version)-mac.tgz") + add_versions("1.9.23", "0adbf2359338e28a80b2ef84c70d8914b56ed1c97ef0135603fcd330ec4c34a1") add_versions("1.20.3", "820f2c7b5360021b9ff361f0868b45613726d6704f9112e8c8cf92d07c7c95b7") elseif is_plat("linux") and is_arch("x86_64") then add_urls("https://github.com/google/filament/releases/download/v$(version)/filament-v$(version)-linux.tgz") + add_versions("1.9.23", "016473371753ff6beb430900eb6550f73acc71c1092cbb654f272ed0666f6210") add_versions("1.20.3", "f57e1c967e09fe73ef69b0db8a48a09b3dab6f9ecb21b906b3f1fbe1d3a2ce3d") end diff --git a/packages/o/open3d/xmake.lua b/packages/o/open3d/xmake.lua new file mode 100644 index 000000000..dd899ebab --- /dev/null +++ b/packages/o/open3d/xmake.lua @@ -0,0 +1,104 @@ +package("open3d") + + set_homepage("http://www.open3d.org/") + set_description("Open3D: A Modern Library for 3D Data Processing") + set_license("MIT") + + add_urls("https://github.com/isl-org/Open3D/archive/refs/tags/$(version).tar.gz", + "https://github.com/isl-org/Open3D.git") + add_versions("v0.15.1", "4bcfbaa6fcbcc14fba46a4d719b9256fffac09b23f8344a7d561b26394159660") + + add_configs("python", {description = "Build the python module.", default = false, type = "boolean"}) + add_configs("cuda", {description = "Enable CUDA support.", default = false, type = "boolean"}) + add_configs("blas", {description = "Choose BLAS vendor.", default = "mkl", type = "string", values = {"mkl", "openblas"}}) + + add_deps("cmake", "nasm") + add_includedirs("include", "include/open3d/3rdparty") + if is_plat("linux") then + add_deps("libx11", "libxrandr", "libxrender", "libxinerama", "libxcursor", "libxfixes", "libxext", "libxi") + end + on_load("windows|x64", "linux|x86_64", "macosx|x86_64", function (package) + if package:config("cuda") then + package:add("deps", "cuda") + end + if package:config("python") then + package:add("deps", "python 3.x") + else + package:add("deps", "python 3.x", {kind = "binary"}) + end + if package:config("blas") ~= "mkl" then + package:add("deps", package:config("blas")) + end + end) + + on_install("windows|x64", "linux|x86_64", "macosx|x86_64", function (package) + if package:is_plat("linux") then + if package:has_tool("cxx", "clang", "clangxx") then + package:add("syslinks", "stdc++fs") + package:add("ldflags", "-fsanitize=safe-stack") + else + raise("GCC compiler is not supported yet, please use LLVM and Clang instead.") + end + end + io.replace("CMakeLists.txt", "add_subdirectory(docs)", "", {plain = true}) + io.replace("CMakeLists.txt", "add_subdirectory(examples)", "", {plain = true}) + io.writefile("examples/test_data/download_file_list.json", "{}") + if package:is_plat("windows") then + local vs = import("core.tool.toolchain").load("msvc"):config("vs") + local vstool + if vs == "2015" then vstool = "vc140" + elseif vs == "2017" then vstool = "vc141" + elseif vs == "2019" then vstool = "vc142" + elseif vs == "2022" then vstool = "vc143" + end + assert(vstool, "unknown vs version: %s", vs) + io.replace("3rdparty/assimp/assimp.cmake", "lib_name assimp%-vc.-%-mt", format("lib_name assimp-%s-mt", vstool)) + end + local configs = {"-DCMAKE_INSTALL_LIBDIR=lib", + "-DCMAKE_FIND_FRAMEWORK=LAST", + "-DBUILD_EXAMPLES=OFF", + "-DBUILD_UNIT_TESTS=OFF", + "-DBUILD_BENCHMARKS=OFF", + "-DBUILD_ISPC_MODULE=OFF", + "-DBUILD_WEBRTC=OFF", + "-DUSE_SYSTEM_BLAS=ON", + "-DBUILD_FILAMENT_FROM_SOURCE=OFF", + "-DWITH_IPPICV=OFF", + "-DPREFER_OSX_HOMEBREW=OFF", + "-DDEVELOPER_BUILD=OFF"} + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) + table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) + table.insert(configs, "-DBUILD_PYTHON_MODULE=" .. (package:config("python") and "ON" or "OFF")) + table.insert(configs, "-DBUILD_CUDA_MODULE=" .. (package:config("cuda") and "ON" or "OFF")) + if package:is_plat("windows") then + table.insert(configs, "-DSTATIC_WINDOWS_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF")) + end + table.insert(configs, "-DUSE_BLAS=" .. (package:config("blas") == "openblas" and "ON" or "OFF")) + if package:is_plat("windows") then + import("package.tools.cmake").install(package, configs, {buildir = os.tmpfile() .. ".dir"}) + elseif package:is_plat("linux") then + import("package.tools.cmake").install(package, configs, {packagedeps = {"libxrandr", "libxrender", "libxinerama", "libxcursor", "libxfixes", "libxext", "libxi", "libx11"}}) + else + import("package.tools.cmake").install(package, configs) + end + if not package:is_plat("windows") then + package:add("links", "Open3D") + for _, f in ipairs(os.files(path.join(package:installdir("lib"), "lib*.a"))) do + if f:match(".+Open3D_3rdparty_.+%.a") then + package:add("links", path.basename(f):match("lib(.+)")) + end + end + end + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + #include + void test() { + using namespace open3d::utility::filesystem; + std::vector filenames; + ListFilesInDirectory(".", filenames); + } + ]]}, {configs = {languages = "c++14"}, includes = "open3d/Open3D.h"})) + end)