package("glog") set_homepage("https://github.com/google/glog/") set_description("C++ implementation of the Google logging module") set_license("BSD-3-Clause") add_urls("https://github.com/google/glog/archive/refs/tags/$(version).tar.gz", "https://github.com/google/glog.git") add_versions("v0.4.0", "f28359aeba12f30d73d9e4711ef356dc842886968112162bc73002645139c39c") add_versions("v0.5.0", "eede71f28371bf39aa69b45de23b329d37214016e2055269b3b5e7cfd40b59f5") local configdeps = {gtest = "gtest", gflags = "gflags", unwind = "libunwind"} for config, dep in pairs(configdeps) do add_configs(config, {description = "Enable " .. dep .. " support.", default = (config == "gflags"), type = "boolean"}) end add_deps("cmake") on_load("windows", "linux", "macosx", function (package) if package:is_plat("windows") and package:version():le("0.4") and not package:config("shared") then package:add("defines", "GOOGLE_GLOG_DLL_DECL=") end for config, dep in pairs(configdeps) do if package:config(config) then package:add("deps", dep) end end end) on_install("windows", "linux", "macosx", function (package) local configs = {"-DBUILD_TESTING=OFF", "-DCMAKE_INSTALL_LIBDIR=lib"} table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) for config, dep in pairs(configdeps) do table.insert(configs, "-DWITH_" .. config:upper() .. "=" .. (package:config(config) and "ON" or "OFF")) end if package:config("pic") ~= false then table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON") end import("package.tools.cmake").install(package, configs) end) on_test(function (package) assert(package:has_cxxfuncs("google::InitGoogleLogging(\"glog\")", {includes = "glog/logging.h"})) end)