Fix static build runtime error.

This commit is contained in:
sdcb 2016-11-21 11:53:06 +08:00
parent 2538bdac5a
commit 51a9334d1b
2 changed files with 20 additions and 0 deletions

View File

@ -30,6 +30,13 @@ if (VCPKG_LIBRARY_LINKAGE STREQUAL static)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin)
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/bson-1.0.lib)
file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/lib/bson-1.0.lib)
# drop the __declspec(dllimport) when building static
vcpkg_apply_patches(
SOURCE_PATH ${CURRENT_PACKAGES_DIR}/include
PATCHES
${CMAKE_CURRENT_LIST_DIR}/static.patch
)
else()
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/bson-static-1.0.lib)
file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/lib/bson-static-1.0.lib)

View File

@ -0,0 +1,13 @@
diff --git a/bson-macros.h b/bson-macros.h
index 909bf6c..0a1f612 100644
--- a/bson-macros.h
+++ b/bson-macros.h
@@ -69,7 +69,7 @@
# ifdef BSON_COMPILATION
# define BSON_API __declspec(dllexport)
# else
-# define BSON_API __declspec(dllimport)
+# define BSON_API
# endif
#elif defined(__GNUC__)
# define BSON_API __attribute__ ((visibility ("default")))