xmake.lua 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package("libkdtree")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/nvmd/libkdtree")
  4. set_description("libkdtree++ is an STL-like C++ template container implementation of k-dimensional space sorting, using a kd-tree. It sports a theoretically unlimited number of dimensions, and can store any data structure")
  5. add_urls("https://github.com/nvmd/libkdtree/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/nvmd/libkdtree.git")
  7. add_versions("0.7.4", "4fd726a8e8a3d759aa2c2f4ec98e6874417ed781a255f94528366506fc87a02b")
  8. on_install(function (package)
  9. os.cp("kdtree++", package:installdir("include"))
  10. end)
  11. on_test(function (package)
  12. assert(package:check_cxxsnippets({test = [[
  13. #include <iostream>
  14. #include <functional>
  15. #include <kdtree++/kdtree.hpp>
  16. struct duplet
  17. {
  18. inline int operator[](int const N) const { return d[N]; }
  19. inline bool operator==(duplet const& other) const {
  20. return this->d[0] == other.d[0] && this->d[1] == other.d[1];
  21. }
  22. inline bool operator!=(duplet const& other) const {
  23. return this->d[0] != other.d[0] || this->d[1] != other.d[1];
  24. }
  25. friend std::ostream& operator<<(std::ostream& o, duplet const& d) {
  26. return o << "(" << d[0] << "," << d[1] << ")";
  27. }
  28. int d[2];
  29. };
  30. typedef KDTree::KDTree<2, duplet, std::function<double(duplet, int)>> duplet_tree_type;
  31. inline double return_dup(duplet d, int k) { return d[k]; }
  32. void test() {
  33. duplet_tree_type dupl_tree_test(std::ref(return_dup));
  34. dupl_tree_test.optimise();
  35. }
  36. ]]}, {configs = {languages = "c++11"}}))
  37. end)