mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Dep/Protobuf: Link protobuf dynamically when building with shared libs
* Fixes issues with linux and dynamic linking * Closes #16993
This commit is contained in:
@@ -57,7 +57,14 @@ else()
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(protobuf STATIC ${protobuf_STAT_SRCS})
|
||||
if (UNIX)
|
||||
# Enable the default unix export behaviour for protobuf so we don't
|
||||
# need to patch it's sources.
|
||||
string(REPLACE "-fvisibility=hidden" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||
string(REPLACE "-fvisibility=hidden" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
endif()
|
||||
|
||||
add_library(protobuf ${protobuf_STAT_SRCS})
|
||||
|
||||
target_include_directories(protobuf
|
||||
PUBLIC
|
||||
@@ -69,7 +76,28 @@ target_link_libraries(protobuf
|
||||
PUBLIC
|
||||
threads)
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(protobuf
|
||||
PRIVATE
|
||||
-DLIBPROTOBUF_EXPORTS
|
||||
-DLIBPROTOC_EXPORTS
|
||||
PUBLIC
|
||||
-DPROTOBUF_USE_DLLS)
|
||||
endif()
|
||||
|
||||
set_target_properties(protobuf
|
||||
PROPERTIES
|
||||
FOLDER
|
||||
"dep")
|
||||
PROPERTIES
|
||||
FOLDER
|
||||
"dep")
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
if (UNIX)
|
||||
install(TARGETS protobuf
|
||||
LIBRARY
|
||||
DESTINATION lib)
|
||||
elseif (WIN32)
|
||||
install(TARGETS protobuf
|
||||
RUNTIME
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user