2
0

xmake.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package("loguru")
  2. set_homepage("https://github.com/emilk/loguru")
  3. set_description("A lightweight C++ logging library")
  4. add_urls("https://github.com/emilk/loguru/archive/refs/tags/$(version).tar.gz",
  5. "https://github.com/emilk/loguru.git")
  6. add_versions("v2.1.0", "1a3be62ebec5609af60b1e094109a93b7412198b896bb88f31dcfe4d95b79ce7")
  7. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  8. add_configs("fmt", {description = "Use fmt to format the log.", default = false, type = "boolean"})
  9. if is_plat("linux") then
  10. add_syslinks("pthread", "dl")
  11. elseif is_plat("bsd") then
  12. add_syslinks("pthread", "dl", "execinfo")
  13. end
  14. on_load(function (package)
  15. if package:config("fmt") then
  16. package:add("deps", "fmt")
  17. package:add("defines", "LOGURU_USE_FMTLIB")
  18. end
  19. end)
  20. on_install(function (package)
  21. io.writefile("xmake.lua", [[
  22. add_rules("mode.debug", "mode.release")
  23. set_languages("cxx11")
  24. option("with_fmt", {default = false, showmenu = true})
  25. if has_config("with_fmt") then
  26. add_requires("fmt")
  27. end
  28. target("loguru")
  29. set_kind("static")
  30. add_files("loguru.cpp")
  31. add_headerfiles("loguru.hpp")
  32. if is_plat("cross") then
  33. add_defines("LOGURU_STACKTRACES=0")
  34. end
  35. if has_config("with_fmt") then
  36. add_packages("fmt")
  37. add_defines("LOGURU_USE_FMTLIB")
  38. end
  39. ]])
  40. import("package.tools.xmake").install(package, {with_fmt = package:config("fmt")})
  41. end)
  42. on_test(function (package)
  43. assert(package:check_cxxsnippets({test = [[
  44. #include <loguru.hpp>
  45. void test(int argc, char* argv[]) {
  46. loguru::init(argc, argv);
  47. LOG_F(INFO, "Hello from main.cpp!");
  48. }
  49. ]]}, {configs = {languages = "c++11"}}))
  50. end)