From 03c8ed4215c410086f37249912608f63203e696b Mon Sep 17 00:00:00 2001 From: Chi Huu Huynh <73843190+Chi-EEE@users.noreply.github.com> Date: Wed, 3 Apr 2024 12:39:43 +0100 Subject: [PATCH] try to fix abseil linking --- packages/p/protobuf-cpp/xmake.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/p/protobuf-cpp/xmake.lua b/packages/p/protobuf-cpp/xmake.lua index 13bbe830c..4790923d0 100644 --- a/packages/p/protobuf-cpp/xmake.lua +++ b/packages/p/protobuf-cpp/xmake.lua @@ -21,7 +21,7 @@ package("protobuf-cpp") add_configs("zlib", {description = "Enable zlib", default = false, type = "boolean"}) - add_deps("cmake", "abseil") + add_deps("cmake") if is_plat("windows") then add_links("libprotobuf") @@ -38,6 +38,9 @@ package("protobuf-cpp") if package:config("zlib") then package:add("deps", "zlib") end + if package:version():gt("3.19.4") then + package:add("deps", "abseil") + end end) on_install("windows", "linux", "macosx", function (package) @@ -45,10 +48,14 @@ package("protobuf-cpp") os.cd("cmake") end io.replace("CMakeLists.txt", "set(protobuf_DEBUG_POSTFIX \"d\"", "set(protobuf_DEBUG_POSTFIX \"\"", {plain = true}) - local configs = {"-Dprotobuf_BUILD_TESTS=OFF", - "-Dprotobuf_BUILD_PROTOC_BINARIES=ON", - "-Dprotobuf_ABSL_PROVIDER=package"} + local configs = {"-Dprotobuf_BUILD_TESTS=OFF", "-Dprotobuf_BUILD_PROTOC_BINARIES=ON"} table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) + local packagedeps = {} + if package:version():gt("3.19.4") then + table.insert(packagedeps, "abseil") + table.insert(configs, "-Dprotobuf_ABSL_PROVIDER=package") + end + if package:is_plat("windows") then table.insert(configs, "-Dprotobuf_MSVC_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF")) if package:config("shared") then @@ -58,7 +65,7 @@ package("protobuf-cpp") if package:config("zlib") then table.insert(configs, "-Dprotobuf_WITH_ZLIB=ON") end - import("package.tools.cmake").install(package, configs, {buildir = "build"}) + import("package.tools.cmake").install(package, configs, {buildir = "build", packagedeps = packagedeps}) os.trycp("build/Release/protoc.exe", package:installdir("bin")) end)