diff options
author | gnaggnoyil <gnaggnoyil@gmail.com> | 2019-07-17 13:08:33 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-07-18 11:40:40 (GMT) |
commit | 3bbd85d5fffe66181cf16c81b23b2ba50f5387ba (patch) | |
tree | 17d652f4e9b7ac9e4a5bced7390b8a2e1b178ab0 /Modules/FindProtobuf.cmake | |
parent | 74ad28fa6a05d033eb99db949eb095fc192c34ad (diff) | |
download | CMake-3bbd85d5fffe66181cf16c81b23b2ba50f5387ba.zip CMake-3bbd85d5fffe66181cf16c81b23b2ba50f5387ba.tar.gz CMake-3bbd85d5fffe66181cf16c81b23b2ba50f5387ba.tar.bz2 |
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.
Diffstat (limited to 'Modules/FindProtobuf.cmake')
-rw-r--r-- | Modules/FindProtobuf.cmake | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index 670352c..2d45965 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -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) |