xmake.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package("octree")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/attcs/Octree")
  4. set_description("Octree/Quadtree/N-dimensional linear tree")
  5. set_license("MIT")
  6. set_urls("https://github.com/attcs/Octree/archive/refs/tags/$(version).tar.gz",
  7. "https://github.com/attcs/Octree.git", {submodules = false})
  8. add_versions("v2.5", "86088cd000254aeddf4f9d75c0600b7f799e062340394124d69760829ed317fe")
  9. on_check(function (package)
  10. if not package:is_arch("x64", "x86", "x86_64") then
  11. raise("package(octree) only support x86 arch")
  12. end
  13. local msvc = package:toolchain("msvc")
  14. if package:is_arch("x64") and msvc then
  15. local vs_toolset = msvc:config("vs_toolset")
  16. if vs_toolset then
  17. local vs_toolset_ver = import("core.base.semver").new(vs_toolset)
  18. local minor = vs_toolset_ver:minor()
  19. assert(minor and minor >= 30, "package(octree) require vs_toolset >= 14.3")
  20. end
  21. end
  22. end)
  23. on_install(function (package)
  24. os.cp("*.h", package:installdir("include"))
  25. end)
  26. on_test(function (package)
  27. assert(package:check_cxxsnippets({test = [[
  28. using namespace OrthoTree;
  29. void test() {
  30. auto constexpr points = std::array{ Point3D{0,0,0}, Point3D{1,1,1}, Point3D{2,2,2} };
  31. auto const octree = OctreePointC(points, 3 /*max depth*/);
  32. auto const searchBox = BoundingBox3D{ {0.5, 0.5, 0.5}, {2.5, 2.5, 2.5} };
  33. auto const pointIDs = octree.RangeSearch(searchBox); //: { 1, 2 }
  34. auto neighborNo = 2;
  35. auto pointIDsByKNN = octree.GetNearestNeighbors(Point3D{ 1.1, 1.1, 1.1 }
  36. , neighborNo
  37. ); //: { 1, 2 }
  38. }
  39. ]]}, {configs = {languages = "c++20"}, includes = "octree.h"}))
  40. end)