xmake.lua 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package("openmvs")
  2. set_homepage("https://github.com/cdcseacave/openMVS")
  3. set_description("open Multi-View Stereo reconstruction library")
  4. set_license("AGPL-3.0")
  5. add_urls("https://github.com/cdcseacave/openMVS/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/cdcseacave/openMVS.git")
  7. add_versions("v2.3.0", "ac7312fb71dbab18c5b2755ad9ac3caa40ec689f6f369c330ca73c87c1f34258")
  8. if is_plat("windows") then
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. end
  11. add_configs("ceres", {description = "Enable CERES optimization library", default = false, type = "boolean"})
  12. add_configs("cuda", {description = "Enable CUDA library", default = false, type = "boolean"})
  13. add_configs("openmp", {description = "Enable OpenMP library", default = true, type = "boolean"})
  14. add_configs("python", {description = "Enable Python library bindings", default = false, type = "boolean"})
  15. add_deps("cmake", "cgal", "eigen <5.0", "glew", "opencv", "vcglib", "zstd")
  16. add_deps("boost", {configs = {iostreams = true, container = true, graph=true, program_options = true, serialization = true, thread = true, zlib = true, zstd = true}})
  17. if on_check then
  18. on_check("linux", function (package)
  19. assert(not package:has_tool("cxx", "clang"), "Linux Clang is not supported yet.")
  20. end)
  21. end
  22. add_includedirs("include", "include/OpenMVS")
  23. add_linkdirs("lib/OpenMVS")
  24. add_links("MVS", "Math", "IO", "Common")
  25. on_load(function (package)
  26. if package:has_tool("cxx", "cl") then
  27. package:add("cxxflags", "/Zc:__cplusplus")
  28. end
  29. if package:config("ceres") then package:add("deps", "ceres-solver") end
  30. if package:config("cuda") then package:add("deps", "cuda") end
  31. if package:config("openmp") then package:add("deps", "openmp") end
  32. if package:config("python") then package:add("deps", "python") end
  33. end)
  34. on_install("windows|!arm64", "linux", function (package)
  35. io.replace("CMakeLists.txt", "# Project-wide settings", [[
  36. # Project-wide settings
  37. find_package(PkgConfig REQUIRED)
  38. pkg_check_modules(libzstd REQUIRED IMPORTED_TARGET libzstd)
  39. ]], {plain = true})
  40. io.replace("libs/Common/Types.h", "#include <new>", "#include <new>\n#include <bitset>", {plain = true})
  41. local configs = {
  42. "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"),
  43. "-DOpenMVS_USE_PYTHON=" .. (package:config("python") and "ON" or "OFF"),
  44. "-DOpenMVS_USE_CERES=" .. (package:config("ceres") and "ON" or "OFF"),
  45. "-DOpenMVS_USE_CUDA=" .. (package:config("cuda") and "ON" or "OFF"),
  46. "-DCGAL_DISABLE_GMP=ON",
  47. "-DOpenMVS_BUILD_TOOLS=OFF",
  48. "-DOpenMVS_ENABLE_TESTS=OFF",
  49. }
  50. import("package.tools.cmake").install(package, configs)
  51. end)
  52. on_test(function (package)
  53. assert(package:check_cxxsnippets({test = [[
  54. #include "MVS.h"
  55. using namespace MVS;
  56. void test() {
  57. SEACAVE::cListTest<true>(100);
  58. SEACAVE::OctreeTest<double,2>(100);
  59. SEACAVE::OctreeTest<float,3>(100);
  60. SEACAVE::TestRayTriangleIntersection<float>(1000);
  61. SEACAVE::TestRayTriangleIntersection<double>(1000);
  62. }
  63. ]]}, {configs = {languages = "c++14"}}))
  64. end)