xmake.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package("tinyxml2")
  2. set_homepage("http://www.grinninglizard.com/tinyxml2/")
  3. set_description("simple, small, efficient, C++ XML parser that can be easily integrating into other programs.")
  4. add_urls("https://github.com/leethomason/tinyxml2/archive/$(version).tar.gz")
  5. add_urls("https://github.com/leethomason/tinyxml2.git")
  6. add_versions("8.0.0", "6ce574fbb46751842d23089485ae73d3db12c1b6639cda7721bf3a7ee862012c")
  7. add_versions("9.0.0", "cc2f1417c308b1f6acc54f88eb70771a0bf65f76282ce5c40e54cfe52952702c")
  8. if is_plat("linux", "macosx", "windows") then
  9. add_deps("cmake")
  10. end
  11. on_install("linux", "macosx", "windows", function (package)
  12. local configs = {"-DBUILD_TESTS=OFF"}
  13. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  14. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  15. import("package.tools.cmake").install(package, configs)
  16. end)
  17. on_install("mingw", "android", "iphoneos", function (package)
  18. io.writefile("xmake.lua", [[
  19. add_rules("mode.debug", "mode.release")
  20. target("tinyxml2")
  21. set_kind("$(kind)")
  22. set_languages("cxx11")
  23. add_headerfiles("tinyxml2.h")
  24. add_files("tinyxml2.cpp")
  25. ]])
  26. import("package.tools.xmake").install(package, {kind = package:configs("shared") and "shared" or "static"})
  27. end)
  28. on_test(function (package)
  29. assert(package:check_cxxsnippets({test = [[
  30. void test(int argc, char** argv) {
  31. static const char* xml = "<element/>";
  32. tinyxml2::XMLDocument doc;
  33. doc.Parse(xml);
  34. }
  35. ]]}, {configs = {languages = "c++11"}, includes = "tinyxml2.h"}))
  36. end)