diff options
author | Naios <naios-dev@live.de> | 2016-04-17 15:54:46 +0200 |
---|---|---|
committer | Naios <naios-dev@live.de> | 2016-04-17 17:36:40 +0200 |
commit | 9701fca7dff0611556e7029874c70a5507c9ca0e (patch) | |
tree | c52217fba169bd3a2fe35fc26bdaea92b194e51a /dep/protobuf | |
parent | 040a54e687d3e7aa8aae328bcb3da8403a4d3155 (diff) |
Dep/Protobuf: Link protobuf dynamically when building with shared libs
* Fixes issues with linux and dynamic linking
* Closes #16993
Diffstat (limited to 'dep/protobuf')
-rw-r--r-- | dep/protobuf/CMakeLists.txt | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/dep/protobuf/CMakeLists.txt b/dep/protobuf/CMakeLists.txt index 5ea6a4e188b..a530cedc970 100644 --- a/dep/protobuf/CMakeLists.txt +++ b/dep/protobuf/CMakeLists.txt @@ -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() |