Skip to content

Commit 0f396bc

Browse files
committed
CVS-171145 Update Protobuf to 6.30.0
- Patching Protobuf (MSVC errors)
1 parent 7231bc8 commit 0f396bc

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

thirdparty/protobuf/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ endif()
9292
# we cannot patch.
9393
set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
9494

95+
# Protobuf 6.30 unconditionally sets ABSL_MSVC_STATIC_RUNTIME=ON for static
96+
# builds (protobuf_BUILD_SHARED_LIBS=OFF), ignoring protobuf_MSVC_STATIC_RUNTIME.
97+
# This causes abseil to compile with /MT while protobuf uses /MD, resulting in
98+
# LNK2038 "mismatch detected for RuntimeLibrary" on MSVC. Patch protobuf's
99+
# CMakeLists.txt to propagate protobuf_MSVC_STATIC_RUNTIME to abseil.
100+
ov_apply_patch(
101+
PATCH "${CMAKE_CURRENT_SOURCE_DIR}/patches/0001-fix-absl-msvc-runtime.patch"
102+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/protobuf")
103+
95104
add_subdirectory(${protobuf_dir} EXCLUDE_FROM_ALL)
96105
get_directory_property(protobuf_VERSION DIRECTORY ${protobuf_dir} DEFINITION protobuf_VERSION)
97106

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index ae3c3246d..d2f4f0b29 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -203,7 +203,7 @@ if (protobuf_BUILD_SHARED_LIBS)
6+
set(protobuf_SHARED_OR_STATIC "SHARED")
7+
else (protobuf_BUILD_SHARED_LIBS)
8+
set(protobuf_SHARED_OR_STATIC "STATIC")
9+
- set(ABSL_MSVC_STATIC_RUNTIME ON)
10+
+ set(ABSL_MSVC_STATIC_RUNTIME ${protobuf_MSVC_STATIC_RUNTIME})
11+
if (protobuf_MSVC_STATIC_RUNTIME)
12+
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>)
13+
else()

0 commit comments

Comments
 (0)