xmake.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package("toml++")
  2. set_homepage("https://marzer.github.io/tomlplusplus/")
  3. set_description("toml++ is a header-only TOML config file parser and serializer for C++17 (and later!).")
  4. set_license("MIT")
  5. add_urls("https://github.com/marzer/tomlplusplus/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/marzer/tomlplusplus.git")
  7. add_versions("v2.5.0", "2e246ee126cfb7bd68edd7285d5bb5c8c5296121ce809306ee71cfd6127c76a6")
  8. add_versions("v3.0.0", "934ad62e82ae5ee67bdef512b39d24ddba45e012fb94e22b39fa1fb192bdabab")
  9. add_versions("v3.1.0", "dae72714fc356ca1b019298d9e6275cc41ba95546ae722ccdb6795e92f47762e")
  10. add_versions("v3.2.0", "aeba776441df4ac32e4d4db9d835532db3f90fd530a28b74e4751a2915a55565")
  11. add_versions("v3.3.0", "fc1a5eb410f3c67e90e5ad1264a1386d020067cfb01b633cc8c0441789aa6cf2")
  12. add_versions("v3.4.0", "8517f65938a4faae9ccf8ebb36631a38c1cadfb5efa85d9a72e15b9e97d25155")
  13. add_configs("header_only", {description = "Use header only version.", default = true, type = "boolean"})
  14. if is_plat("mingw") and is_subhost("msys") then
  15. add_extsources("pacman::tomlplusplus")
  16. elseif is_plat("linux") then
  17. add_extsources("pacman::tomlplusplus", "apt::libtomlplusplus-dev")
  18. elseif is_plat("macosx") then
  19. add_extsources("brew::tomlplusplus")
  20. end
  21. on_load(function (package)
  22. if package:config("header_only") then
  23. package:set("kind", "library", {headeronly = true})
  24. package:add("deps", "cmake")
  25. else
  26. package:add("deps", "meson", "ninja")
  27. end
  28. end)
  29. on_install(function (package)
  30. if package:config("header_only") then
  31. import("package.tools.cmake").install(package)
  32. else
  33. package:add("defines", "TOML_HEADER_ONLY=0")
  34. local configs = {"-Dbuild_lib=true"}
  35. table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
  36. import("package.tools.meson").install(package, configs)
  37. end
  38. end)
  39. on_test(function (package)
  40. assert(package:check_cxxsnippets({test = [[
  41. #include <iostream>
  42. #include <sstream>
  43. #include <toml++/toml.h>
  44. using namespace std::string_view_literals;
  45. static void test() {
  46. static constexpr std::string_view some_toml = R"(
  47. [library]
  48. name = "toml++"
  49. authors = ["Mark Gillard <[email protected]>"]
  50. cpp = 17
  51. )"sv;
  52. auto tbl = toml::parse(some_toml);
  53. std::cout << tbl << "\n";
  54. }
  55. ]]}, {configs = {languages = "c++17"}, includes = "toml++/toml.h"}))
  56. end)