xmake.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package("poselib")
  2. set_homepage("https://github.com/PoseLib/PoseLib")
  3. set_description("Minimal solvers for calibrated camera pose estimation")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/PoseLib/PoseLib/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/PoseLib/PoseLib.git")
  7. add_versions("v2.0.5", "a9493e6725c58e6ae541fe416c0a6179185a60006880ff3ddf32737a43695668")
  8. add_versions("v2.0.4", "caa0c1c9b882f6e36b5ced6f781406ed97d4c1f0f61aa31345ebe54633d67c16")
  9. -- https://github.com/PoseLib/PoseLib/issues/157
  10. if is_plat("windows") then
  11. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  12. end
  13. add_deps("cmake")
  14. add_deps("eigen")
  15. on_install("!wasm and (!windows or windows|!arm64)", function (package)
  16. io.replace("CMakeLists.txt", "-march=native", "", {plain = true})
  17. io.replace("CMakeLists.txt", "-Wall -Werror -fPIC", "", {plain = true})
  18. local configs = {}
  19. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  20. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  21. if package:config("shared") and package:is_plat("windows") then
  22. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  23. end
  24. import("package.tools.cmake").install(package, configs)
  25. end)
  26. on_test(function (package)
  27. assert(package:check_cxxsnippets({test = [[
  28. void test() {
  29. std::vector<Eigen::Vector3d> x1(10, Eigen::Vector3d{});
  30. std::vector<Eigen::Vector3d> x2(10, Eigen::Vector3d{});
  31. Eigen::Matrix3d h;
  32. int res = poselib::homography_4pt(x1, x2, &h);
  33. }
  34. ]]}, {configs = {languages = "c++17"}, includes = "PoseLib/poselib.h"}))
  35. end)