xmake.lua 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package("scnlib")
  2. set_homepage("https://scnlib.readthedocs.io/")
  3. set_description("scnlib is a modern C++ library for replacing scanf and std::istream")
  4. set_urls("https://github.com/eliaskosunen/scnlib/archive/refs/tags/v$(version).zip")
  5. add_versions("1.1.2", "72bf304662b03e00de5b438b9d4697a081e786d589e067817c356174fb2cb06c")
  6. add_versions("0.4", "49a84f1439e52666532fbd5da3fa1d652622fc7ac376070e330e15c528d38190")
  7. add_configs("header_only", {description = "Use header only version.", default = false, type = "boolean"})
  8. on_load(function (package)
  9. if package:config("header_only") then
  10. package:add("defines", "SCN_HEADER_ONLY=1")
  11. else
  12. package:add("deps", "cmake")
  13. end
  14. end)
  15. on_install(function (package)
  16. if package:config("header_only") then
  17. os.cp("include/scn", package:installdir("include"))
  18. return
  19. end
  20. local configs = {"-DSCN_TESTS=OFF", "-DSCN_DOCS=OFF", "-DSCN_EXAMPLES=OFF", "-DSCN_BENCHMARKS=OFF", "-DSCN_PENDANTIC=OFF", "-DSCN_BUILD_FUZZING=OFF"}
  21. import("package.tools.cmake").install(package, configs)
  22. end)
  23. on_test(function (package)
  24. assert(package:check_cxxsnippets({test = [[
  25. #include <scn/scn.h>
  26. #include <cstdio>
  27. static void test() {
  28. int i;
  29. scn::prompt("What's your favorite number? ", "{}", i);
  30. printf("Oh, cool, %d!", i);
  31. }
  32. ]]}, {configs = {languages = "c++17"}, includes = "scn/scn.h"}))
  33. end)