xmake.lua 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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.2.1", "841f49f2e045b9c6365997c2a8fbf76e6f215042dda4511a5bb04bc5ebc7f88a")
  9. add_versions("v3.2.0", "9f43fa972532e5df6c5fd5ad0f5bac606cdec541ccaf1732463d8070bbb7f03b")
  10. add_versions("v3.1.1", "523175f792eb0ff04f9e653c90746c12655f10cb70f1d5e6d6d9491420298a08")
  11. add_versions("v3.0.0", "36f41fa2a46b3c1466613b63f3fa73dc24d912bc90d667147f1e43215a8c6d00")
  12. add_versions("v2.2.0", "447dbfc2361fce9742c5d1c9cfb25731c977b405f9085a738fbd608626da8a4d")
  13. if is_plat("mingw") and is_subhost("msys") then
  14. add_extsources("pacman::cxxopts")
  15. elseif is_plat("linux") then
  16. add_extsources("pacman::cxxopts-git", "apt::libcxxopts-dev")
  17. elseif is_plat("macosx") then
  18. add_extsources("brew::cxxopts")
  19. end
  20. add_deps("cmake")
  21. on_install(function (package)
  22. local configs = {"-DCXXOPTS_BUILD_EXAMPLES=OFF", "-DCXXOPTS_BUILD_TESTS=OFF"}
  23. import("package.tools.cmake").install(package, configs)
  24. end)
  25. on_test(function (package)
  26. assert(package:check_cxxsnippets({test = [[
  27. static void test() {
  28. cxxopts::Options options("MyProgram", "One line description of MyProgram");
  29. options.add_options()
  30. ("d,debug", "Enable debugging") // a bool parameter
  31. ("i,integer", "Int param", cxxopts::value<int>())
  32. ("f,file", "File name", cxxopts::value<std::string>())
  33. ("v,verbose", "Verbose output", cxxopts::value<bool>()->default_value("false"));
  34. }
  35. ]]}, {configs = {languages = "c++14"}, includes = "cxxopts.hpp"}))
  36. end)