diff --git a/packages/g/geos/xmake.lua b/packages/g/geos/xmake.lua index 04b87f0b4..0f7372b02 100644 --- a/packages/g/geos/xmake.lua +++ b/packages/g/geos/xmake.lua @@ -12,6 +12,9 @@ package("geos") local configs = {"-DBUILD_BENCHMARKS=OFF", "-DBUILD_TESTING=OFF"} 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")) + if package:config("pic") ~= false then + table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON") + end import("package.tools.cmake").install(package, configs) end) diff --git a/packages/g/gflags/xmake.lua b/packages/g/gflags/xmake.lua new file mode 100644 index 000000000..9333670b6 --- /dev/null +++ b/packages/g/gflags/xmake.lua @@ -0,0 +1,43 @@ +package("gflags") + + set_homepage("https://github.com/gflags/gflags/") + set_description("The gflags package contains a C++ library that implements commandline flags processing.") + set_license("BSD-3-Clause") + + add_urls("https://github.com/gflags/gflags/archive/refs/tags/$(version).tar.gz", + "https://github.com/gflags/gflags.git") + add_versions("v2.2.2", "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf") + + add_configs("mt", {description = "Build the multi-threaded gflags library.", default = false, type = "boolean"}) + + add_deps("cmake") + if is_plat("windows") then + add_syslinks("shlwapi") + elseif is_plat("linux") then + add_syslinks("pthread") + end + on_install("windows", "linux", "macosx", function (package) + local configs = {"-DBUILD_TESTING=OFF"} + 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")) + if package:config("mt") then + table.insert(configs, "-DBUILD_gflags_LIB=ON") + table.insert(configs, "-DBUILD_gflags_nothreads_LIB=OFF") + else + table.insert(configs, "-DBUILD_gflags_LIB=OFF") + table.insert(configs, "-DBUILD_gflags_nothreads_LIB=ON") + 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:check_cxxsnippets({test = [[ + void test() { + using GFLAGS_NAMESPACE::SetUsageMessage; + SetUsageMessage("Usage message"); + } + ]]}, {configs = {languages = "c++11"}, includes = "gflags/gflags.h"})) + end) diff --git a/packages/g/glog/xmake.lua b/packages/g/glog/xmake.lua new file mode 100644 index 000000000..e8541e175 --- /dev/null +++ b/packages/g/glog/xmake.lua @@ -0,0 +1,34 @@ +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_deps("cmake") + add_deps("gflags", "gtest", "libunwind", {optional = true}) + on_load("windows", function (package) + if not package:config("shared") then + package:add("defines", "GOOGLE_GLOG_DLL_DECL=") + end + end) + + on_install("windows", "linux", "macosx", function (package) + local configs = {"-DBUILD_TESTING=OFF"} + 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")) + table.insert(configs, "-DWITH_GTEST=" .. (package:dep("gtest"):exists() and "ON" or "OFF")) + table.insert(configs, "-DWITH_GFLAGS=" .. (package:dep("gflags"):exists() and "ON" or "OFF")) + table.insert(configs, "-DWITH_UNWIND=" .. (package:dep("libunwind"):exists() and "ON" or "OFF")) + 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)