xmake.lua 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package("bqlog")
  2. set_homepage("https://github.com/Tencent/BqLog")
  3. set_description("Maybe the world's fastest logging library, originating from the client of the top mobile game Honor of Kings, is lightweight, works on PC, mobile, and servers, supports C#, Java, and C++, and is well adapted to Unity and Unreal engines.")
  4. add_urls("https://github.com/Tencent/BqLog/archive/refs/tags/Release_$(version).tar.gz",
  5. "https://github.com/Tencent/BqLog.git")
  6. add_versions("1.4.4", "c32a8eae1f935a0dfc2d67e93b0d6cad6a0c551d65e72b10713da304ab33ee11")
  7. if is_plat("windows", "mingw") then
  8. add_syslinks("shell32")
  9. elseif is_plat("linux") then
  10. add_syslinks("pthread")
  11. elseif is_plat("bsd") then
  12. add_syslinks("pthread", "execinfo")
  13. elseif is_plat("android") then
  14. add_syslinks("log", "android")
  15. elseif is_plat("iphoneos") then
  16. add_frameworks("Security", "UIKit")
  17. end
  18. add_deps("cmake")
  19. if on_check then
  20. on_check("windows", function (package)
  21. local vs_toolset = package:toolchain("msvc"):config("vs_toolset")
  22. if vs_toolset then
  23. local vs_toolset_ver = import("core.base.semver").new(vs_toolset)
  24. local minor = vs_toolset_ver:minor()
  25. assert(minor and minor >= 30, "package(bqlog) require vs_toolset >= 14.3")
  26. end
  27. end)
  28. end
  29. on_install("windows|x64", "linux", "macosx", "bsd", "android", "iphoneos", function (package)
  30. if package:config("shared") then
  31. package:add("defines", "BQ_DYNAMIC_LIB_IMPORT")
  32. end
  33. local configs = {}
  34. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  35. table.insert(configs, "-DBUILD_TYPE=" .. (package:config("shared") and "dynamic_lib" or "static_lib"))
  36. local plat = package:plat()
  37. if package:is_plat("windows", "mingw") then
  38. plat = "win64"
  39. elseif package:is_plat("macosx") then
  40. plat = "mac"
  41. elseif package:is_plat("iphoneos") then
  42. plat = "ios"
  43. elseif not package:is_plat("android", "linux") then
  44. plat = "unix"
  45. end
  46. table.insert(configs, "-DTARGET_PLATFORM=" .. plat)
  47. io.writefile("CMakeLists.txt", [[
  48. cmake_minimum_required(VERSION 3.22)
  49. add_subdirectory(src)
  50. include(GNUInstallDirs)
  51. install(TARGETS BqLog
  52. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  53. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  54. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  55. )
  56. install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
  57. ]])
  58. io.replace("src/CMakeLists.txt", "/WX", "", {plain = true})
  59. io.replace("src/CMakeLists.txt", "-Werror", "", {plain = true})
  60. io.replace("src/CMakeLists.txt", [[set_xcode_property(BqLog GCC_GENERATE_DEBUGGING_SYMBOLS NO "ALL")]],
  61. [[ macro (set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE)
  62. set_xcode_property(BqLog GCC_GENERATE_DEBUGGING_SYMBOLS NO "ALL")
  63. endmacro (set_xcode_property)
  64. ]], {plain = true})
  65. import("package.tools.cmake").install(package, configs)
  66. end)
  67. on_test(function (package)
  68. assert(package:check_cxxsnippets({test = [[
  69. #include <string>
  70. void test() {
  71. std::string config;
  72. auto log = bq::log::create_log("my_first_log", config);
  73. }
  74. ]]}, {configs = {languages = "c++17"}, includes = "bq_log/bq_log.h"}))
  75. end)