Files
gentoo/dev-libs/libmongocrypt/files/libmongocrypt-1.15.2-static.patch

76 lines
3.5 KiB
Diff

cmake/ImportBSON.cmake | 44 ++++++++++++++++----------------------------
1 file changed, 16 insertions(+), 28 deletions(-)
diff --git a/cmake/ImportBSON.cmake b/cmake/ImportBSON.cmake
index c2ca766f..2c58a088 100644
--- a/cmake/ImportBSON.cmake
+++ b/cmake/ImportBSON.cmake
@@ -105,6 +105,15 @@ if (NOT DEFINED MONGOCRYPT_MONGOC_DIR)
include (FetchMongoC)
# The FetchMongoC module defines a MONGOCRYPT_MONGOC_DIR for us to use
endif ()
+find_package (bson-1.0 REQUIRED)
+if (ENABLE_ONLINE_TESTS)
+ find_package (mongoc-1.0 REQUIRED)
+endif ()
+if (ENABLE_ONLINE_TESTS)
+ if(NOT TARGET mongo::bson_static AND NOT TARGET mongo::mongoc_static)
+ message (FATAL_ERROR "Online tests require static build of libbson and libmongoc")
+ endif ()
+endif ()
function (_import_bson)
if (MONGOCRYPT_MONGOC_DIR STREQUAL "USE-SYSTEM" AND USE_SHARED_LIBBSON AND NOT ENABLE_ONLINE_TESTS)
@@ -183,9 +192,6 @@ function (_import_bson)
endif ()
endfunction ()
-# Do the import in a function to isolate variable scope
-_import_bson ()
-
# Define interface targets to be used to control the libbson used at both build and import time.
# Refer to mongocrypt-config.cmake to see how these targets are used by consumers
add_library (_mongocrypt-libbson_for_static INTERFACE)
@@ -201,34 +207,16 @@ install (
# The mongocrypt-config file will later add the appropriate link library for downstream
# users during find_package()
if (USE_SHARED_LIBBSON)
- target_link_libraries (_mongocrypt-libbson_for_shared INTERFACE $<BUILD_INTERFACE:bson_shared>)
+ target_link_libraries (_mongocrypt-libbson_for_shared INTERFACE $<BUILD_INTERFACE:mongo::bson_shared>)
+ target_link_libraries (_mongocrypt-libbson_for_static INTERFACE $<BUILD_INTERFACE:mongo::bson_shared>)
else ()
- target_link_libraries (_mongocrypt-libbson_for_shared INTERFACE $<BUILD_INTERFACE:bson_static>)
+ target_link_libraries (_mongocrypt-libbson_for_shared INTERFACE $<BUILD_INTERFACE:mongo::bson_static>)
+ target_link_libraries (_mongocrypt-libbson_for_static INTERFACE $<BUILD_INTERFACE:mongo::bson_static>)
endif ()
-# libbson_for_static always links to the static libbson:
-target_link_libraries (_mongocrypt-libbson_for_static INTERFACE $<BUILD_INTERFACE:bson_static>)
-if (TARGET mongoc_static)
+if (TARGET mongo::mongoc_static)
# And an alias to the mongoc target for use in some test cases
+ add_library (mongoc_static INTERFACE)
+ target_link_libraries (mongoc_static INTERFACE $<BUILD_INTERFACE:mongo::mongoc_static>)
add_library (_mongocrypt::mongoc ALIAS mongoc_static)
endif ()
-
-# Put the libbson dynamic library into the current binary directory (plus possible config suffix).
-# This ensures that libbson DLL will resolve on Windows when it searches during tests
-set_property (TARGET bson_shared PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
-
-if (ENABLE_STATIC)
- # We are going to build a static libmongocrypt.
- # We want the static libbson target from the embedded mongoc. Enable the static library as
- # part of "all", and install the archive alongside the rest of our static libraries.
- # (Useful for some users for convenience of static-linking libmongocrypt: CDRIVER-3187)
- set_target_properties (bson_static PROPERTIES
- EXCLUDE_FROM_ALL FALSE
- OUTPUT_NAME bson-static-for-libmongocrypt
- )
- install (
- FILES $<TARGET_FILE:bson_static>
- DESTINATION "${CMAKE_INSTALL_LIBDIR}"
- RENAME ${CMAKE_STATIC_LIBRARY_PREFIX}bson-static-for-libmongocrypt${CMAKE_STATIC_LIBRARY_SUFFIX}
- )
-endif ()