xmake.lua 6.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package("pcl")
  2. set_homepage("https://pointclouds.org/")
  3. set_description("The Point Cloud Library (PCL) is a standalone, large scale, open project for 2D/3D image and point cloud processing.")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/PointCloudLibrary/pcl/archive/refs/tags/pcl-$(version).tar.gz",
  6. "https://github.com/PointCloudLibrary/pcl.git")
  7. add_versions("1.12.0", "21dfa9a268de9675c1f94d54d9402e4e02120a0aa4215d064436c52b7d5bd48f")
  8. add_versions("1.12.1", "dc0ac26f094eafa7b26c3653838494cc0a012bd1bdc1f1b0dc79b16c2de0125a")
  9. add_versions("1.14.0", "de297b929eafcb93747f12f98a196efddf3d55e4edf1b6729018b436d5be594d")
  10. add_versions("1.14.1", "5dc5e09509644f703de9a3fb76d99ab2cc67ef53eaf5637db2c6c8b933b28af6")
  11. add_versions("1.15.1", "e1d862c7b6bd27a45884a825a2e509bfcbd4561307d5bfe17ce5c8a3d94a6c29")
  12. add_patches("1.14.1", "patches/1.14.1/clang.patch", "01bf08ac7eafc5748d38fdabac1be3b18b9ec1b2e88a4f458a2cfab3dfac5356")
  13. add_patches("1.14.1", "patches/1.14.1/msbuild.patch", "2a256b8916d8c32c204bf0ec57b279d212856a5a1b28ef174aaa63e14554d082")
  14. add_configs("cuda", {description = "Build with cuda", default = false, type = "boolean"})
  15. add_configs("glew", {description = "Build with glew", default = true, type = "boolean"})
  16. add_configs("libpng", {description = "Build with libpng", default = true, type = "boolean"})
  17. add_configs("libusb", {description = "Build with libusb", default = true, type = "boolean"})
  18. add_configs("opengl", {description = "Build with opengl", default = true, type = "boolean"})
  19. add_configs("openmp", {description = "Build with openmp", default = false, type = "boolean"})
  20. add_configs("libpcap", {description = "Build with pcap", default = false, type = "boolean"})
  21. add_configs("qhull", {description = "Build with qhull", default = true, type = "boolean"})
  22. add_configs("vtk", {description = "Build with vtk", default = false, type = "boolean"})
  23. add_configs("visualization", {description = "Build visualization", default = false, type = "boolean"})
  24. add_configs("apps", {description = "Build apps", default = false, type = "boolean"})
  25. add_configs("tools", {description = "Build tools", default = false, type = "boolean"})
  26. add_configs("qt", {description = "Build with qt", default = "AUTO", type = "string", values = {"AUTO", "YES", "QT6", "QT5", "NO"}})
  27. add_deps("cmake")
  28. add_deps("cjson", "eigen", "flann", "lz4", "nanoflann", "zlib")
  29. on_load(function (package)
  30. package:add("includedirs", "include/pcl-" .. package:version():major() .. "." .. package:version():minor())
  31. if package:version():le("1.14.1") then
  32. package:add("deps", "boost", {version = "1.85.0", configs = {filesystem = true, serialization = true, date_time = true, iostreams = true, system = true, thread = true, graph = true}})
  33. else
  34. package:add("deps", "boost", {configs = {asio = true, filesystem = true, serialization = true, date_time = true, iostreams = true, system = true, thread = true, graph = true}})
  35. end
  36. local confs = {"cuda", "glew", "libpng", "libusb", "opengl", "openmp", "libpcap", "qhull", "vtk"}
  37. for _, conf in ipairs(confs) do
  38. if package:config(conf) then
  39. package:add("deps", conf)
  40. end
  41. end
  42. end)
  43. on_install("windows", "linux", "macosx", function (package)
  44. io.replace("CMakeLists.txt", "set(CMAKE_CXX_FLAGS_DEFAULT \"/DWIN32 /D_WINDOWS /W3 /GR /EHsc\")", "set(CMAKE_CXX_FLAGS_DEFAULT \" /DWIN32 /D_WINDOWS /W3 /GR /EHsc\")\nstring(APPEND CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_DEFAULT})", {plain = true})
  45. io.replace("CMakeLists.txt", "find_package(GLEW QUIET)", "find_package(GLEW CONFIG)", {plain = true})
  46. io.replace("cmake/Modules/FindFLANN.cmake", "flann_cpp", "flann")
  47. if package:version():le("1.12.0") then
  48. io.replace("cmake/pcl_options.cmake", "set(CMAKE_FIND_LIBRARY_SUFFIXES", "#set(CMAKE_FIND_LIBRARY_SUFFIXES", {plain = true})
  49. end
  50. local configs = {
  51. "-DBUILD_examples=OFF",
  52. "-DBoost_USE_STATIC_LIBS=ON",
  53. "-DPCL_ALLOW_BOTH_SHARED_AND_STATIC_DEPENDENCIES=ON"
  54. }
  55. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  56. table.insert(configs, "-DPCL_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  57. table.insert(configs, "-DWITH_QT=" .. package:config("qt"))
  58. table.insert(configs, "-DBUILD_apps=" .. (package:config("apps") and "ON" or "OFF"))
  59. table.insert(configs, "-DBUILD_tools=" .. (package:config("tools") and "ON" or "OFF"))
  60. table.insert(configs, "-DBUILD_visualization=" .. (package:config("visualization") and "ON" or "OFF"))
  61. local confs = { "cuda", "glew", "libusb", "opengl", "openmp", "qhull", "vtk" }
  62. for _, conf in ipairs(confs) do
  63. table.insert(configs, "-DWITH_" .. conf:upper() .. "=" .. (package:config(conf) and "ON" or "OFF"))
  64. end
  65. table.insert(configs, "-DWITH_PCAP=" .. (package:config("libpcap") and "ON" or "OFF"))
  66. table.insert(configs, "-DWITH_PNG=" .. (package:config("libpng") and "ON" or "OFF"))
  67. if package:is_plat("windows") then
  68. table.insert(configs, "-DBoost_USE_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  69. end
  70. local opt = {packagedeps = {"lz4", "dl"}}
  71. if package:config("shared") and package:is_plat("macosx") then
  72. opt.shflags = {"-framework", "CoreFoundation", "-framework", "IOKit", "-framework", "Security"}
  73. end
  74. import("package.tools.cmake").install(package, configs, opt)
  75. package:addenv("PATH", "bin")
  76. end)
  77. on_test(function (package)
  78. assert(package:check_cxxsnippets({test = [[
  79. void test() {
  80. using PointT = pcl::PointXYZI;
  81. pcl::PointCloud<PointT>::Ptr cloud (new pcl::PointCloud<PointT>);
  82. }
  83. ]]}, {configs = {languages = package:version():gt("1.15") and "c++17" or "c++14"}, includes = {"pcl/point_cloud.h", "pcl/point_types.h"}}))
  84. end)