xmake.lua 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package("log4cplus")
  2. set_homepage("https://sourceforge.net/projects/log4cplus/")
  3. set_description("log4cplus is a simple to use C++ logging API providing thread-safe, flexible, and arbitrarily granular control over log management and configuration.")
  4. set_license("BSD-2-Clause")
  5. add_urls("https://github.com/log4cplus/log4cplus/releases/download/REL_$(version).tar.gz", {version = function (version) return version:gsub("%.", "_") .. "/log4cplus-" .. version end})
  6. add_versions("2.1.2", "e2673815ea34886f29b2213fff19cc1a6707a7e65099927a19ea49b4eb018822")
  7. add_versions("2.1.1", "42dc435928917fd2f847046c4a0c6086b2af23664d198c7fc1b982c0bfe600c1")
  8. add_versions("2.0.6", "5fb26433b0f200ebfc2e6effb7e2e5131185862a2ea9a621a8e7f3f725a72b08")
  9. add_versions("2.0.7", "086451c7e7c582862cbd6c60d87bb6d9d63c4b65321dba85fa71766382f7ec6d")
  10. add_configs("unicode", {description = "Use unicode charset.", default = true, type = "boolean"})
  11. if is_plat("windows", "mingw") then
  12. add_syslinks("advapi32", "ws2_32")
  13. elseif is_plat("linux", "bsd") then
  14. add_syslinks("pthread")
  15. end
  16. add_deps("cmake")
  17. on_load(function (package)
  18. if package:config("unicode") then
  19. package:add("defines", "UNICODE")
  20. end
  21. if package:is_plat("windows") and package:config("shared") then
  22. package:add("defines", "LOG4CPLUS_BUILD_DLL")
  23. end
  24. end)
  25. on_install(function (package)
  26. local configs = {
  27. "-DLOG4CPLUS_BUILD_TESTING=OFF",
  28. "-DWITH_UNIT_TESTS=OFF",
  29. "-DLOG4CPLUS_ENABLE_DECORATED_LIBRARY_NAME=OFF",
  30. }
  31. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  32. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  33. table.insert(configs, "-DUNICODE=" .. (package:config("unicode") and "ON" or "OFF"))
  34. if package:is_plat("wasm") then
  35. table.insert(configs, "-DLOG4CPLUS_BUILD_LOGGINGSERVER=OFF")
  36. end
  37. import("package.tools.cmake").install(package, configs)
  38. end)
  39. on_test(function (package)
  40. assert(package:check_cxxsnippets({test = [[
  41. void test() {
  42. log4cplus::Initializer initializer;
  43. log4cplus::BasicConfigurator config;
  44. config.configure();
  45. log4cplus::Logger logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("main"));
  46. LOG4CPLUS_WARN(logger, LOG4CPLUS_TEXT("Hello, World!"));
  47. }
  48. ]]}, {configs = {languages = "c++17"}, includes = "log4cplus/log4cplus.h"}))
  49. end)