xmake.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package("glog")
  2. set_homepage("https://github.com/google/glog/")
  3. set_description("C++ implementation of the Google logging module")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/google/glog/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/google/glog.git")
  7. add_versions("v0.4.0", "f28359aeba12f30d73d9e4711ef356dc842886968112162bc73002645139c39c")
  8. add_versions("v0.5.0", "eede71f28371bf39aa69b45de23b329d37214016e2055269b3b5e7cfd40b59f5")
  9. add_versions("v0.6.0", "8a83bf982f37bb70825df71a9709fa90ea9f4447fb3c099e1d720a439d88bad6")
  10. local configdeps = {gtest = "gtest", gflags = "gflags", unwind = "libunwind"}
  11. for config, dep in pairs(configdeps) do
  12. add_configs(config, {description = "Enable " .. dep .. " support.", default = (config == "gflags"), type = "boolean"})
  13. end
  14. add_deps("cmake")
  15. if is_plat("linux") then
  16. add_syslinks("pthread")
  17. end
  18. on_load("windows", "linux", "macosx", "android", "iphoneos", "cross", function (package)
  19. if package:is_plat("windows") then
  20. if package:version():le("0.4") and not package:config("shared") then
  21. package:add("defines", "GOOGLE_GLOG_DLL_DECL=")
  22. end
  23. package:add("defines", "GLOG_NO_ABBREVIATED_SEVERITIES")
  24. end
  25. for config, dep in pairs(configdeps) do
  26. if package:config(config) then
  27. package:add("deps", dep)
  28. end
  29. end
  30. end)
  31. on_install("windows", "linux", "macosx", "android", "iphoneos", "cross", function (package)
  32. local configs = {"-DBUILD_TESTING=OFF", "-DCMAKE_INSTALL_LIBDIR=lib"}
  33. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  34. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  35. for config, dep in pairs(configdeps) do
  36. table.insert(configs, "-DWITH_" .. config:upper() .. "=" .. (package:config(config) and "ON" or "OFF"))
  37. end
  38. import("package.tools.cmake").install(package, configs)
  39. end)
  40. on_test(function (package)
  41. assert(package:has_cxxfuncs("google::InitGoogleLogging(\"glog\")", {includes = "glog/logging.h"}))
  42. end)