xmake.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package("quill")
  2. set_homepage("https://github.com/odygrd/quill")
  3. set_description("Asynchronous Low Latency C++ Logging Library")
  4. set_urls("https://github.com/odygrd/quill/archive/refs/tags/v$(version).tar.gz",
  5. "https://github.com/odygrd/quill.git")
  6. add_versions("2.8.0", "0461a6c314e3d882f3b9ada487ef1bf558925272509ee41a9fd25f7776db6075")
  7. add_versions("2.9.0", "dec64c0fbb4bfbafe28fdeeeefac10206285bf2be4a42ec5dfb7987ca4ccb372")
  8. add_versions("2.9.1", "921e053118136f63cebb2ca1d7e42456fd0bf9626facb755884709092753c054")
  9. add_versions("3.3.1", "f929d54a115b45c32dd2acd1a9810336d35c31fde9f5581c51ad2b80f980d0d1")
  10. if is_plat("macosx") then
  11. add_extsources("brew::quill")
  12. end
  13. add_configs("fmt_external", {description = "Use external fmt library instead of bundled.", default = false, type = "boolean"})
  14. add_configs("noexcept", {description = "Build without exceptions with -fno-exceptions flag", default = false, type = "boolean"})
  15. if is_plat("mingw") then
  16. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  17. end
  18. add_deps("cmake")
  19. if is_plat("linux") then
  20. add_syslinks("pthread")
  21. end
  22. on_load(function (package)
  23. if package:config("fmt_external") then
  24. package:add("deps", "fmt")
  25. package:add("defines", "QUILL_FMT_EXTERNAL")
  26. end
  27. end)
  28. on_install("windows", "linux", "macosx", "mingw", function (package)
  29. local configs = {"-DQUILL_ENABLE_INSTALL=ON"}
  30. if package:config("shared") and package:is_plat("windows") then
  31. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  32. end
  33. if package:config("fmt_external") then
  34. table.insert(configs, "-DQUILL_FMT_EXTERNAL=ON")
  35. end
  36. if package:config("noexcept") then
  37. table.insert(configs, "-DQUILL_NO_EXCEPTIONS=ON")
  38. end
  39. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  40. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  41. import("package.tools.cmake").install(package, configs)
  42. end)
  43. on_test(function (package)
  44. assert(package:check_cxxsnippets({test = [[
  45. #include <quill/Quill.h>
  46. void test() {
  47. quill::Config cfg;
  48. cfg.enable_console_colours = true;
  49. quill::configure(cfg);
  50. quill::start();
  51. quill::Logger* logger = quill::get_logger();
  52. logger->set_log_level(quill::LogLevel::TraceL3);
  53. logger->init_backtrace(2, quill::LogLevel::Critical);
  54. }
  55. ]]}, {configs = {languages = "c++17"}}))
  56. end)