Skip to content

Commit 7325ca9

Browse files
committed
New^3 attempt to fix Windows builds
1 parent eb1a3de commit 7325ca9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

cpp/cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,6 +1923,27 @@ function(build_protobuf)
19231923

19241924
fetchcontent_makeavailable(protobuf)
19251925

1926+
# Ensure protobuf targets don't have PROTOBUF_USE_DLLS defined
1927+
# This is critical on Windows to avoid DLL import/export issues when linking static protobuf
1928+
if(TARGET protobuf::libprotobuf)
1929+
get_target_property(_protobuf_compile_defs protobuf::libprotobuf
1930+
INTERFACE_COMPILE_DEFINITIONS)
1931+
if(_protobuf_compile_defs)
1932+
list(REMOVE_ITEM _protobuf_compile_defs PROTOBUF_USE_DLLS)
1933+
set_target_properties(protobuf::libprotobuf PROPERTIES INTERFACE_COMPILE_DEFINITIONS
1934+
"${_protobuf_compile_defs}")
1935+
endif()
1936+
endif()
1937+
if(TARGET protobuf::libprotoc)
1938+
get_target_property(_protoc_compile_defs protobuf::libprotoc
1939+
INTERFACE_COMPILE_DEFINITIONS)
1940+
if(_protoc_compile_defs)
1941+
list(REMOVE_ITEM _protoc_compile_defs PROTOBUF_USE_DLLS)
1942+
set_target_properties(protobuf::libprotoc PROPERTIES INTERFACE_COMPILE_DEFINITIONS
1943+
"${_protoc_compile_defs}")
1944+
endif()
1945+
endif()
1946+
19261947
# Get the actual include directory from the protobuf target
19271948
# For FetchContent, this points to the source directory which contains the .proto files
19281949
set(PROTOBUF_INCLUDE_DIR "${protobuf_SOURCE_DIR}/src")

0 commit comments

Comments
 (0)