xmake.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package("lastools")
  2. set_homepage("https://github.com/LAStools/LAStools")
  3. set_description("efficient tools for LiDAR processing")
  4. set_license("LGPL-2.0")
  5. add_urls("https://github.com/LAStools/LAStools/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/LAStools/LAStools.git")
  7. add_versions("v2.0.3", "b6c6ac33835ead2c69d05e282febc266048ba071a71dae6fdad321d532dfcf78")
  8. add_configs("cmake", {description = "Use cmake buildsystem", default = false, type = "boolean"})
  9. add_configs("tools", {description = "Build tools", default = false, type = "boolean"})
  10. on_load(function (package)
  11. if package:config("cmake") then
  12. package:add("deps", "cmake")
  13. end
  14. if package:is_plat("windows") and package:config("shared") then
  15. package:add("defines", "USE_AS_DLL")
  16. end
  17. end)
  18. on_install(function (package)
  19. local enable_tools = package:config("tools")
  20. if package:config("cmake") then
  21. if not enable_tools then
  22. io.replace("CMakeLists.txt", "add_subdirectory(src)", "", {plain = true})
  23. end
  24. local configs = {}
  25. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  26. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  27. local opt = {}
  28. opt.cxflags = "/utf-8"
  29. import("package.tools.cmake").install(package, configs, opt)
  30. os.cp("LASlib/lib/*.lib", package:installdir("lib"))
  31. os.cp("LASlib/lib/*.dll", package:installdir("bin"))
  32. else
  33. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  34. import("package.tools.xmake").install(package, {tools = enable_tools})
  35. end
  36. end)
  37. on_test(function (package)
  38. assert(package:check_cxxsnippets({test = [[
  39. #include <LASlib/lasreader.hpp>
  40. #include <LASlib/laswriter.hpp>
  41. void test() {
  42. LASreadOpener lasreadopener;
  43. LASwriteOpener laswriteopener;
  44. }
  45. ]]}, {configs = {languages = "c++14"}}))
  46. end)