xmake.lua 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package("cartographer")
  2. set_homepage("https://github.com/cartographer-project/cartographer")
  3. set_description("Cartographer is a system that provides real-time simultaneous localization and mapping (SLAM) in 2D and 3D across multiple platforms and sensor configurations.")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/cartographer-project/cartographer/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/cartographer-project/cartographer.git")
  7. add_versions("1.0.0", "474a410bf6457eb8a0fd92ea412d7889fb013051e625d3ee25e8d65e4113fd6c")
  8. add_versions("2.0.0", "abba0daa348095a5e821ee5e8037bad5d06f89f4c21ea850da5ab8a7e6997a2a")
  9. add_patches("1.0.0", path.join(os.scriptdir(), "patches", "1.0.0", "fix-build-error.patch"), "a4bb53d6f098c77a397d72c244d4283af1f9eec8a4ca7a7fa28de77b06d1201e")
  10. add_patches("1.0.0", path.join(os.scriptdir(), "patches", "1.0.0", "remove-boost.patch"), "bd0666bbf4eff2f4fda0c6bd55c960fd60af848f7d750a9c1efaffda2abc1e9b")
  11. add_patches("2.0.0", path.join(os.scriptdir(), "patches", "2.0.0", "fix-build-error.patch"), "5b59ffeb1ef339759e8def5c3a4e4793d5efc9d2af6feb782cae09afd3dd7a04")
  12. add_patches("2.0.0", path.join(os.scriptdir(), "patches", "2.0.0", "remove-boost.patch"), "9b323141681748e3191c9964c7774bbb5acf17292dda76554763da4999a6358e")
  13. if is_plat("windows") then
  14. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  15. end
  16. add_deps("cmake")
  17. add_deps("zlib")
  18. add_deps("ceres-solver 2.1.0", {configs = {suitesparse = true}})
  19. add_deps("protobuf-cpp 3.19.4")
  20. add_deps("abseil", "cairo", "eigen", "lua")
  21. on_install("windows|x64", "windows|x86", "macosx|x86_64", "linux", function (package)
  22. for _, headerfile in ipairs(os.files("cartographer/**.h")) do
  23. io.replace(headerfile, "cairo/cairo.h", "cairo.h", {plain = true})
  24. end
  25. for _, file in ipairs(table.join(os.files("cartographer/**.cc"), os.files("cartographer/**.h"))) do
  26. io.replace(file, "LOCKS_EXCLUDED", "ABSL_LOCKS_EXCLUDED", {plain = true})
  27. io.replace(file, "GUARDED_BY", "ABSL_GUARDED_BY", {plain = true})
  28. io.replace(file, "EXCLUSIVE_LOCKS_REQUIRED", "ABSL_EXCLUSIVE_LOCKS_REQUIRED", {plain = true})
  29. end
  30. for _, protofile in ipairs(os.files("cartographer/**.proto")) do
  31. io.replace(protofile, [[import "cartographer/]], [[import "]], {plain = true})
  32. end
  33. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  34. io.replace("cartographer/common/configuration_file_resolver.cc", [[#include "cartographer/common/config.h"]], "", {plain = true})
  35. io.replace("cartographer/common/configuration_file_resolver.cc", [[configuration_files_directories_.push_back(kConfigurationFilesDirectory);]], "", {plain = true})
  36. local configs = {}
  37. import("package.tools.xmake").install(package, configs)
  38. end)
  39. on_test(function (package)
  40. assert(package:check_cxxsnippets({test = [[
  41. #include "cartographer/mapping/proto/map_builder_options.pb.h"
  42. void test() {
  43. cartographer::mapping::proto::MapBuilderOptions map_builder_options;
  44. }
  45. ]]}, {configs = {languages = "c++17"}}))
  46. end)