xmake.lua 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package("sdformat")
  2. set_homepage("http://sdformat.org/")
  3. set_description("Simulation Description Format (SDFormat) parser and description files.")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/gazebosim/sdformat/archive/refs/tags/sdformat16_$(version).tar.gz")
  6. add_urls("https://github.com/gazebosim/sdformat.git", {alias = "git"})
  7. add_versions("16.0.1", "4fac898700afb2953af5f8ac6b0221e4d9bc1e460aac6d4b7a5c3699c456126c")
  8. add_versions("git:16.0.1", "sdformat16_16.0.1")
  9. add_includedirs("include", "include/gz/sdformat16")
  10. add_deps("cmake", "python 3.x", "gz-cmake 5.x", {kind = "binary"})
  11. add_deps("gz-math 9.x", "urdfdom")
  12. on_check("mingw", "iphoneos", function (package)
  13. raise("package(sdformat) dep(urdfdom) unsupported this platform")
  14. end)
  15. on_check("android|armeabi-v7a", function (package)
  16. local ndk = package:toolchain("ndk")
  17. local ndk_sdkver = ndk:config("ndk_sdkver")
  18. if tonumber(ndk_sdkver) < 24 then
  19. raise("package(sdformat) dep(urdfdom) unsupported this platform")
  20. end
  21. end)
  22. on_install(function (package)
  23. if package:config("shared") then
  24. package:add("defines", "GZ_SDFORMAT_STATIC_DEFINE")
  25. end
  26. -- Remove gz-cmake find_package, it will be broken on some platform.
  27. io.replace("src/CMakeLists.txt", "GzURDFDOM::GzURDFDOM", "", {plain = true})
  28. io.replace("src/CMakeLists.txt", "add_subdirectory(cmd)", [[
  29. find_package(urdfdom CONFIG REQUIRED)
  30. find_package(console_bridge CONFIG REQUIRED)
  31. find_package(tinyxml2 CONFIG REQUIRED)
  32. target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE urdfdom::urdfdom_model urdfdom::urdfdom_world)
  33. add_subdirectory(cmd)
  34. ]], {plain = true})
  35. local configs = {"-DBUILD_TESTING=OFF", "-DSKIP_PYBIND11=ON"}
  36. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  37. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  38. import("package.tools.cmake").install(package, configs)
  39. end)
  40. on_test(function (package)
  41. assert(package:check_cxxsnippets({test = [[
  42. void test(int argc, char **argv) {
  43. auto sdf = sdf::readFile(argv[1]);
  44. }
  45. ]]}, {configs = {languages = "c++17"}, includes = "sdf/sdf.hh"}))
  46. end)