Merge pull request #6165 from xuhongxu96/grpc-static-linux

[grpc] Supported static linking in Linux
This commit is contained in:
Curtis J Bezault 2019-04-23 17:05:47 -05:00 committed by GitHub
commit 1028346321
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 2 deletions

View File

@ -0,0 +1,16 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3839e22..91720a9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -99,6 +99,11 @@ set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
add_definitions(-DPB_FIELD_32BIT)
+if (gRPC_STATIC_LINKING)
+ # Force to static link
+ set(CMAKE_EXE_LINKER_FLAGS "-Bstatic")
+endif()
+
if (MSVC)
include(cmake/msvc_static_runtime.cmake)
add_definitions(-D_WIN32_WINNT=0x600 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS)

View File

@ -1,4 +1,4 @@
Source: grpc
Version: 1.19.1
Version: 1.19.1-1
Build-Depends: zlib, openssl, protobuf, c-ares (!uwp)
Description: An RPC library and framework

View File

@ -14,7 +14,9 @@ vcpkg_from_github(
REF v1.19.1
SHA512 4bb127d946fc16887fd4cf75215f0bc9f6d17dbd36fc4f1b191a64914f96c49dddb41f1b6c72fd24ea0a40f242b4398248f32fcb1fe9a764367be1c2edda9142
HEAD_REF master
PATCHES fix-uwp.patch
PATCHES
00001-fix-uwp.patch
00002-static-linking-in-linux.patch
)
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
@ -29,6 +31,12 @@ else()
set(gRPC_MSVC_STATIC_RUNTIME OFF)
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(gRPC_STATIC_LINKING ON)
else()
set(gRPC_STATIC_LINKING OFF)
endif()
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
set(cares_CARES_PROVIDER OFF)
else()
@ -41,6 +49,7 @@ vcpkg_configure_cmake(
OPTIONS
-DgRPC_INSTALL=ON
-DgRPC_BUILD_TESTS=OFF
-DgRPC_STATIC_LINKING=${gRPC_STATIC_LINKING}
-DgRPC_MSVC_STATIC_RUNTIME=${gRPC_MSVC_STATIC_RUNTIME}
-DgRPC_ZLIB_PROVIDER=package
-DgRPC_SSL_PROVIDER=package