Browse Source

protobuf-cpp: Fix Windows build for versions <= 3.19.4 (#5955)

* protobuf-cpp: fix port_def.inc modification for versions <= 3.19.4

* protobuf-cpp: use recommended API to retrieve runtimes
Doekin 8 months ago
parent
commit
117ffb8a6c
1 changed files with 5 additions and 4 deletions
  1. 5 4
      packages/p/protobuf-cpp/xmake.lua

+ 5 - 4
packages/p/protobuf-cpp/xmake.lua

@@ -128,6 +128,10 @@ package("protobuf-cpp")
     end)
     end)
 
 
     on_install(function (package)
     on_install(function (package)
+        if package:is_plat("windows", "mingw") then
+            io.replace("src/google/protobuf/port_def.inc", "#define PROTOBUF_DESCRIPTOR_WEAK_MESSAGES_ALLOWED", "", {plain = true})
+        end
+
         local version = package:version()
         local version = package:version()
         if version:le("3.19.4") then
         if version:le("3.19.4") then
             os.cd("cmake")
             os.cd("cmake")
@@ -138,9 +142,6 @@ package("protobuf-cpp")
         if version:ge("26.1") then
         if version:ge("26.1") then
             io.replace("cmake/abseil-cpp.cmake", "BUILD_SHARED_LIBS AND MSVC", "FALSE", {plain = true})
             io.replace("cmake/abseil-cpp.cmake", "BUILD_SHARED_LIBS AND MSVC", "FALSE", {plain = true})
         end
         end
-        if package:is_plat("windows", "mingw") then
-            io.replace("src/google/protobuf/port_def.inc", "#define PROTOBUF_DESCRIPTOR_WEAK_MESSAGES_ALLOWED", "", {plain = true})
-        end
 
 
         local configs = {
         local configs = {
             "-Dprotobuf_BUILD_TESTS=OFF",
             "-Dprotobuf_BUILD_TESTS=OFF",
@@ -153,7 +154,7 @@ package("protobuf-cpp")
         table.insert(configs, "-Dprotobuf_DISABLE_RTTI=" .. (package:config("rtti") and "OFF" or "ON"))
         table.insert(configs, "-Dprotobuf_DISABLE_RTTI=" .. (package:config("rtti") and "OFF" or "ON"))
         if package:is_plat("windows") then
         if package:is_plat("windows") then
             table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
             table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
-            table.insert(configs, "-Dprotobuf_MSVC_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
+            table.insert(configs, "-Dprotobuf_MSVC_STATIC_RUNTIME=" .. (package:has_runtime("MT", "MTd") and "ON" or "OFF"))
         end
         end
 
 
         table.insert(configs, "-Dprotobuf_WITH_ZLIB=" .. (package:config("zlib") and "ON" or "OFF"))
         table.insert(configs, "-Dprotobuf_WITH_ZLIB=" .. (package:config("zlib") and "ON" or "OFF"))