File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff 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" )
You can’t perform that action at this time.
0 commit comments