Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
link to icu or sasl2 when appropriate for mongo
Browse files Browse the repository at this point in the history
mongo-c-driver could require linkage to libicu or libsasl2 depending on how it was configured when built. We can't just use MONGOC_STATIC_LIBRARIES variables from its cmake file because these static variants may try to static link against libraries we don't want (like a system libc/c++). But we need to know if mongo c driver was built with ICU or SASL2 support so hat we can continue to link to those. This certainly is a bit on the fragile side but try to parse what is included in MONGOC_STATIC_LIBRARIES to see what we should link to
  • Loading branch information
spoonincode committed Apr 26, 2019
1 parent 0349bfb commit 884714f
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion plugins/mongo_db_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,28 @@ if(BUILD_MONGO_DB_PLUGIN)
PRIVATE ${LIBMONGOCXX_STATIC_DEFINITIONS} ${LIBBSONCXX_STATIC_DEFINITIONS}
)

# We can't just use *_STATIC_LIBRARIES variables to link against because the static
# variants of these may try to static link against libraries we don't want (like a system
# libc/c++). But we need to know if mongo c driver was built with ICU or SASL2 support so
# that we can continue to link to those. This certainly is a bit on the fragile side but
# try to parse what is included in MONGOC_STATIC_LIBRARIES to see what we should link to
foreach(MONGO_S_LIB ${MONGOC_STATIC_LIBRARIES})
string(REGEX MATCH "libsasl2\\${CMAKE_SHARED_LIBRARY_SUFFIX}$" REGOUT ${MONGO_S_LIB})
if(REGOUT)
set(LINK_SASL "sasl2")
endif()

string(REGEX MATCH "libicuuc\\${CMAKE_SHARED_LIBRARY_SUFFIX}$" REGOUT ${MONGO_S_LIB})
if(REGOUT)
set(LINK_ICU "icuuc")
endif()
endforeach()

target_link_libraries(mongo_db_plugin
PUBLIC chain_plugin eosio_chain appbase
${LIBMONGOCXX_STATIC_LIBRARY_PATH} ${LIBBSONCXX_STATIC_LIBRARY_PATH}
${MONGOC_STATIC_LIBRARY} ${BSON_STATIC_LIBRARY}
resolv
resolv ${LINK_SASL} ${LINK_ICU}
)

else()
Expand Down

0 comments on commit 884714f

Please sign in to comment.