xmake.lua 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/v$(version).tar.gz")
  6. add_versions("2.3.0", "ac7312fb71dbab18c5b2755ad9ac3caa40ec689f6f369c330ca73c87c1f34258")
  7. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  8. add_configs("ceres", {description = "Enable CERES optimization library", default = false, type = "boolean"})
  9. add_configs("cuda", {description = "Enable CUDA library", default = false, type = "boolean"})
  10. add_configs("openmp", {description = "Enable OpenMP library", default = true, type = "boolean"})
  11. add_configs("python", {description = "Enable Python library bindings", default = false, type = "boolean"})
  12. add_deps("cmake", "eigen", "glew", "opencv", "cgal", "vcglib", "zstd")
  13. add_deps("boost", {configs = {iostreams = true, container = true, graph=true, program_options = true, serialization = true, thread = true, zlib = true, zstd = true}})
  14. on_load("windows", function (package)
  15. package:add("defines", "BOOST_ALL_NO_LIB") -- disable boost auto-linking
  16. if package:toolchain("msvc") then package:add("cxxflags", "/Zc:__cplusplus") end -- enable msvc __cplusplus
  17. if package:config("ceres") then package:add("deps", "ceres-solver") end
  18. if package:config("cuda") then package:add("deps", "cuda") end
  19. if package:config("openmp") then package:add("deps", "openmp") end
  20. if package:config("python") then package:add("deps", "python") end
  21. end)
  22. on_install("windows|x64", "windows|x86", function (package)
  23. io.replace("CMakeLists.txt", "# Project-wide settings", [[
  24. # Project-wide settings
  25. find_package(PkgConfig REQUIRED)
  26. pkg_check_modules(libzstd REQUIRED IMPORTED_TARGET libzstd)
  27. ]], {plain = true})
  28. io.replace("libs/Common/Types.h", "#include <new>", "#include <new>\n#include <bitset>", {plain = true})
  29. local configs = {
  30. "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"),
  31. "-DOpenMVS_USE_PYTHON=" .. (package:config("python") and "ON" or "OFF"),
  32. "-DOpenMVS_USE_CERES=" .. (package:config("ceres") and "ON" or "OFF"),
  33. "-DOpenMVS_USE_CUDA=" .. (package:config("cuda") and "ON" or "OFF"),
  34. "-DCGAL_DISABLE_GMP=ON",
  35. "-DOpenMVS_BUILD_TOOLS=OFF",
  36. "-DOpenMVS_ENABLE_TESTS=OFF",
  37. }
  38. import("package.tools.cmake").install(package, configs)
  39. package:add("linkdirs", "lib/OpenMVS")
  40. local libs = os.files(package:installdir("lib/OpenMVS/*.lib"))
  41. for _, filepath in ipairs(libs) do
  42. package:add("links", path.basename(filepath))
  43. end
  44. end)
  45. on_test(function (package)
  46. assert(package:check_cxxsnippets({test = [[
  47. #include <openMVS/MVS.h>
  48. using namespace MVS;
  49. void test() {
  50. SEACAVE::cListTest<true>(100);
  51. SEACAVE::OctreeTest<double,2>(100);
  52. SEACAVE::OctreeTest<float,3>(100);
  53. SEACAVE::TestRayTriangleIntersection<float>(1000);
  54. SEACAVE::TestRayTriangleIntersection<double>(1000);
  55. }
  56. ]]}, {configs = {languages = "c++11"}}))
  57. end)