Commit 3bbd85d5 authored by gnaggnoyil's avatar gnaggnoyil Committed by Brad King

FindProtobuf: Fix usage of protobuf dynamic libraries on Windows

Define `PROTOBUF_USE_DLLS` on Windows when linking against dynamic
protobuf libraries so that we import symbols from them.

We use the condition `MSVC` to enable this because that is what
the upstream buildsystem uses.
parent 74ad28fa
......@@ -526,6 +526,11 @@ if(Protobuf_INCLUDE_DIR)
INTERFACE_COMPILE_FEATURES cxx_std_11
)
endif()
if (MSVC AND NOT Protobuf_USE_STATIC_LIBS)
set_property(TARGET protobuf::libprotobuf APPEND PROPERTY
INTERFACE_COMPILE_DEFINITIONS "PROTOBUF_USE_DLLS"
)
endif()
if(UNIX AND TARGET Threads::Threads)
set_property(TARGET protobuf::libprotobuf APPEND PROPERTY
INTERFACE_LINK_LIBRARIES Threads::Threads)
......@@ -554,6 +559,11 @@ if(Protobuf_INCLUDE_DIR)
set_target_properties(protobuf::libprotobuf-lite PROPERTIES
IMPORTED_LOCATION_DEBUG "${Protobuf_LITE_LIBRARY_DEBUG}")
endif()
if (MSVC AND NOT Protobuf_USE_STATIC_LIBS)
set_property(TARGET protobuf::libprotobuf-lite APPEND PROPERTY
INTERFACE_COMPILE_DEFINITIONS "PROTOBUF_USE_DLLS"
)
endif()
if(UNIX AND TARGET Threads::Threads)
set_property(TARGET protobuf::libprotobuf-lite APPEND PROPERTY
INTERFACE_LINK_LIBRARIES Threads::Threads)
......@@ -587,6 +597,11 @@ if(Protobuf_INCLUDE_DIR)
INTERFACE_COMPILE_FEATURES cxx_std_11
)
endif()
if (MSVC AND NOT Protobuf_USE_STATIC_LIBS)
set_property(TARGET protobuf::libprotoc APPEND PROPERTY
INTERFACE_COMPILE_DEFINITIONS "PROTOBUF_USE_DLLS"
)
endif()
if(UNIX AND TARGET Threads::Threads)
set_property(TARGET protobuf::libprotoc APPEND PROPERTY
INTERFACE_LINK_LIBRARIES Threads::Threads)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment