mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-25 18:29:01 +08:00
0f04ebaf57
* fix mongo-c-driver build for Linux
116 lines
4.0 KiB
Diff
116 lines
4.0 KiB
Diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 5beb610..7e74ff7 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -55,6 +55,7 @@
|
|
|
|
include(MaintainerFlags)
|
|
|
|
+if ((NOT ENABLE_STATIC STREQUAL ON) AND (NOT ENABLE_STATIC STREQUAL AUTO))
|
|
# The input variable BSON_ROOT_DIR is respected for backwards compatibility,
|
|
# but you should use the standard CMAKE_PREFIX_PATH instead.
|
|
message (STATUS "Searching for libbson CMake packages")
|
|
@@ -67,12 +68,14 @@
|
|
message ("-- libbson found version \"${BSON_VERSION}\"")
|
|
message ("-- libbson include path \"${BSON_INCLUDE_DIRS}\"")
|
|
message ("-- libbson libraries \"${BSON_LIBRARIES}\"")
|
|
+endif ()
|
|
|
|
if (ENABLE_STATIC STREQUAL ON OR ENABLE_STATIC STREQUAL AUTO)
|
|
find_package (libbson-static-1.0
|
|
"${MONGOC_MAJOR_VERSION}.${MONGOC_MINOR_VERSION}.${MONGOC_MICRO_VERSION}"
|
|
HINTS
|
|
- ${BSON_ROOT_DIR})
|
|
+ ${BSON_ROOT_DIR}
|
|
+ REQUIRED)
|
|
|
|
if (ENABLE_STATIC STREQUAL ON AND NOT BSON_STATIC_LIBRARY)
|
|
message (FATAL_ERROR "Static libbson not found. Pass -DENABLE_STATIC=OFF")
|
|
@@ -627,6 +630,7 @@
|
|
set (LIBS ${LIBS} ws2_32)
|
|
endif()
|
|
|
|
+if (NOT MONGOC_ENABLE_STATIC)
|
|
add_library(mongoc_shared SHARED ${SOURCES} ${HEADERS})
|
|
set_target_properties(mongoc_shared PROPERTIES CMAKE_CXX_VISIBILITY_PRESET hidden)
|
|
target_link_libraries (mongoc_shared ${LIBS} ${BSON_LIBRARIES})
|
|
@@ -638,6 +642,7 @@
|
|
# This hack sets up standard symlink, libmongoc-1.0.so -> libmongoc-1.0.0.so
|
|
set_target_properties(mongoc_shared PROPERTIES VERSION 0 SOVERSION ${MONGOC_MAJOR_VERSION})
|
|
set_target_properties(mongoc_shared PROPERTIES OUTPUT_NAME "mongoc-${MONGOC_API_VERSION}" PREFIX "lib")
|
|
+endif ()
|
|
|
|
if (MONGOC_ENABLE_STATIC)
|
|
add_library(mongoc_static STATIC ${SOURCES} ${HEADERS})
|
|
@@ -804,6 +809,7 @@
|
|
file(COPY ${SOURCE_DIR}/tests/x509gen DESTINATION ${PROJECT_BINARY_DIR}/tests)
|
|
file(COPY ${SOURCE_DIR}/tests/release_files DESTINATION ${PROJECT_BINARY_DIR}/tests)
|
|
|
|
+if (NOT MONGOC_ENABLE_STATIC)
|
|
install(
|
|
TARGETS mongoc_shared ${EXAMPLES}
|
|
LIBRARY DESTINATION lib
|
|
@@ -810,10 +816,11 @@
|
|
ARCHIVE DESTINATION lib
|
|
RUNTIME DESTINATION bin
|
|
)
|
|
+endif ()
|
|
|
|
if (MONGOC_ENABLE_STATIC)
|
|
install(
|
|
- TARGETS mongoc_shared mongoc_static ${EXAMPLES}
|
|
+ TARGETS mongoc_static ${EXAMPLES}
|
|
LIBRARY DESTINATION lib
|
|
ARCHIVE DESTINATION lib
|
|
RUNTIME DESTINATION bin
|
|
index 5beb610..7e74ff7 100644
|
|
--- a/src/mongoc/mongoc-gridfs-file.c
|
|
+++ b/src/mongoc/mongoc-gridfs-file.c
|
|
@@ -753,7 +753,7 @@ _mongoc_gridfs_file_refresh_page (mongoc_gridfs_file_t *file)
|
|
bson_t query;
|
|
bson_t child;
|
|
bson_t opts;
|
|
- const bson_t *chunk;
|
|
+ const bson_t *chunk = 0;
|
|
const char *key;
|
|
bson_iter_t iter;
|
|
int64_t existing_chunks;
|
|
diff --git a/src/mongoc/mongoc-handshake.c b/src/mongoc/mongoc-handshake.c
|
|
index 4e181bd..b274fc1 100644
|
|
--- a/src/mongoc/mongoc-handshake.c
|
|
+++ b/src/mongoc/mongoc-handshake.c
|
|
@@ -243,7 +243,8 @@ _get_os_version (void)
|
|
char *ret = bson_malloc (HANDSHAKE_OS_VERSION_MAX);
|
|
bool found = false;
|
|
|
|
-#ifdef _WIN32
|
|
+#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
|
|
+#elif defined (_WIN32)
|
|
OSVERSIONINFO osvi;
|
|
ZeroMemory (&osvi, sizeof (OSVERSIONINFO));
|
|
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
|
|
diff --git a/src/mongoc/mongoc-util.c b/src/mongoc/mongoc-util.c
|
|
index a4e50ea..4f631e7 100644
|
|
--- a/src/mongoc/mongoc-util.c
|
|
+++ b/src/mongoc/mongoc-util.c
|
|
@@ -70,6 +70,11 @@ void
|
|
_mongoc_usleep (int64_t usec)
|
|
{
|
|
#ifdef _WIN32
|
|
+#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
|
|
+ if (usec / 1000 > MAXDWORD || usec < 0)
|
|
+ __fastfail(-1);
|
|
+ Sleep((DWORD)(usec / 1000));
|
|
+#else
|
|
LARGE_INTEGER ft;
|
|
HANDLE timer;
|
|
|
|
@@ -80,6 +85,7 @@ _mongoc_usleep (int64_t usec)
|
|
SetWaitableTimer (timer, &ft, 0, NULL, NULL, 0);
|
|
WaitForSingleObject (timer, INFINITE);
|
|
CloseHandle (timer);
|
|
+#endif
|
|
#else
|
|
BSON_ASSERT (usec >= 0);
|
|
usleep ((useconds_t) usec);
|