Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions ports/grpc/00012-vcpkg-cross-compile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ad15a31..1529acd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -284,6 +284,16 @@ if(WIN32)
set(_gRPC_BASELIB_LIBRARIES wsock32 ws2_32 crypt32 gdi32)
endif()

+# VCPKG cross compile support
+if(VCPKG_HOST_TRIPLET AND NOT VCPKG_HOST_TRIPLET STREQUAL VCPKG_TARGET_TRIPLET)
+ set(CMAKE_CROSSCOMPILING ON)
+ set(_gRPC_CPP_PLUGIN "${_VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/tools/grpc/grpc_cpp_plugin")
+ if(NOT EXISTS "${_gRPC_CPP_PLUGIN}")
+ message(WARNING "${_gRPC_CPP_PLUGIN} is not installed. Cross compile might fail. Try to install grpc:${VCPKG_HOST_TRIPLET}")
+ unset(_gRPC_CPP_PLUGIN)
+ endif()
+endif()
+
# Create directory for generated .proto files
set(_gRPC_PROTO_GENS_DIR ${CMAKE_BINARY_DIR}/gens)
file(MAKE_DIRECTORY ${_gRPC_PROTO_GENS_DIR})
1 change: 1 addition & 0 deletions ports/grpc/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Source: grpc
Version: 1.33.1
Port-Version: 1
Build-Depends: zlib, openssl, protobuf, c-ares (!uwp), upb, abseil, re2
Homepage: https://github.com/grpc/grpc
Description: An RPC library and framework
Expand Down
1 change: 1 addition & 0 deletions ports/grpc/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ vcpkg_from_github(
00009-use-system-upb.patch
00010-add-feature-absl-sync.patch
00011-fix-csharp_plugin.patch
00012-vcpkg-cross-compile.patch
snprintf.patch
)

Expand Down
2 changes: 1 addition & 1 deletion ports/protobuf/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: protobuf
Version: 3.13.0
Port-Version: 2
Port-Version: 3
Homepage: https://github.com/protocolbuffers/protobuf
Description: Protocol Buffers - Google's data interchange format

Expand Down
14 changes: 14 additions & 0 deletions ports/protobuf/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,17 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.3)
cmake_policy(POP)
endif()
_find_package(${ARGS})

if(Protobuf_FOUND AND VCPKG_HOST_TRIPLET AND NOT VCPKG_HOST_TRIPLET STREQUAL VCPKG_TARGET_TRIPLET)
foreach(prop IMPORTED_LOCATION IMPORTED_LOCATION_RELEASE IMPORTED_LOCATION_DEBUG)
get_target_property(_protoc_exe_path protobuf::protoc ${prop})
if(_protoc_exe_path)
string(REPLACE "/${VCPKG_TARGET_TRIPLET}/" "/${VCPKG_HOST_TRIPLET}/" _protoc_exe_path "${_protoc_exe_path}")
if(NOT EXISTS "${_protoc_exe_path}")
message(WARNING "${_protoc_exe_path} is not installed. Cross compile might fail. Try to install protobuf:${VCPKG_HOST_TRIPLET}")
else()
set_target_properties(protobuf::protoc PROPERTIES ${prop} "${_protoc_exe_path}")
endif()
endif()
endforeach()
endif()
20 changes: 20 additions & 0 deletions scripts/buildsystems/vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,26 @@ endif()
set(VCPKG_TARGET_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_TARGET_TRIPLET_PLAT} CACHE STRING "Vcpkg target triplet (ex. x86-windows)")
set(_VCPKG_TOOLCHAIN_DIR ${CMAKE_CURRENT_LIST_DIR})

if(VCPKG_HOST_TRIPLET)
set(VCPKG_HOST_TRIPLET ${VCPKG_HOST_TRIPLET} CACHE STRING "Vcpkg host triplet (ex. arm64-linux)" FORCE)
else()
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
set(_VCPKG_HOST_TRIPLET_PLAT linux)
endif()

if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "armv7l")
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(_VCPKG_TARGET_TRIPLET_ARCH arm64)
endif()

if(_VCPKG_HOST_TRIPLET_PLAT AND _VCPKG_TARGET_TRIPLET_ARCH)
set(VCPKG_HOST_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_HOST_TRIPLET_PLAT} CACHE STRING "Vcpkg host triplet (ex. arm64-linux)")
endif()
endif()

if(NOT DEFINED _VCPKG_ROOT_DIR)
# Detect .vcpkg-root to figure VCPKG_ROOT_DIR
set(_VCPKG_ROOT_DIR_CANDIDATE ${CMAKE_CURRENT_LIST_DIR})
Expand Down