xmake.lua 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package("cxxopts")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/jarro2783/cxxopts")
  4. set_description("Lightweight C++ command line option parser")
  5. set_license("MIT")
  6. add_urls("https://github.com/jarro2783/cxxopts.git")
  7. add_urls("https://github.com/jarro2783/cxxopts/archive/$(version).tar.gz")
  8. add_versions("v3.1.1", "523175f792eb0ff04f9e653c90746c12655f10cb70f1d5e6d6d9491420298a08")
  9. add_versions("v3.0.0", "36f41fa2a46b3c1466613b63f3fa73dc24d912bc90d667147f1e43215a8c6d00")
  10. add_versions("v2.2.0", "447dbfc2361fce9742c5d1c9cfb25731c977b405f9085a738fbd608626da8a4d")
  11. if is_plat("mingw") and is_subhost("msys") then
  12. add_extsources("pacman::cxxopts")
  13. elseif is_plat("linux") then
  14. add_extsources("pacman::cxxopts-git", "apt::libcxxopts-dev")
  15. elseif is_plat("macosx") then
  16. add_extsources("brew::cxxopts")
  17. end
  18. add_deps("cmake")
  19. on_install(function (package)
  20. local configs = {"-DCXXOPTS_BUILD_EXAMPLES=OFF", "-DCXXOPTS_BUILD_TESTS=OFF"}
  21. import("package.tools.cmake").install(package, configs)
  22. end)
  23. on_test(function (package)
  24. assert(package:check_cxxsnippets({test = [[
  25. static void test() {
  26. cxxopts::Options options("MyProgram", "One line description of MyProgram");
  27. options.add_options()
  28. ("d,debug", "Enable debugging") // a bool parameter
  29. ("i,integer", "Int param", cxxopts::value<int>())
  30. ("f,file", "File name", cxxopts::value<std::string>())
  31. ("v,verbose", "Verbose output", cxxopts::value<bool>()->default_value("false"));
  32. }
  33. ]]}, {configs = {languages = "c++14"}, includes = "cxxopts.hpp"}))
  34. end)