diff --git a/build/CommonTargets.CMake b/build/CommonTargets.CMake index 038fb63..4dee9f9 100644 --- a/build/CommonTargets.CMake +++ b/build/CommonTargets.CMake @@ -8,65 +8,37 @@ ExternalProject_Add(GTest ) set(_FINDPACKAGE_GTEST_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}/GTest/lib/cmake/GTest") -set(COMMON_GRPC_CACHE_ARGS - -DABSL_ENABLE_INSTALL:BOOL=ON - -DABSL_PROPAGATE_CXX_STD:BOOL=ON - -DBUILD_SHARED_LIBS:BOOL=OFF - -DBUILD_TESTING:BOOL=OFF - -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD} - -DgRPC_BUILD_CSHARP_EXT:BOOL=OFF - -DgRPC_BUILD_GRPC_CPP_PLUGIN:BOOL=ON - -DgRPC_BUILD_GRPC_CSHARP_PLUGIN:BOOL=OFF - -DgRPC_BUILD_GRPC_NODE_PLUGIN:BOOL=OFF - -DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN:BOOL=OFF - -DgRPC_BUILD_GRPC_PHP_PLUGIN:BOOL=OFF - -DgRPC_BUILD_GRPC_PYTHON_PLUGIN:BOOL=OFF - -DgRPC_BUILD_GRPC_RUBY_PLUGIN:BOOL=OFF - -DgRPC_INSTALL:BOOL=ON - -Dprotobuf_ABSL_PROVIDER:STRING=package - -Dprotobuf_MODULE_COMPATIBLE:BOOL=ON - -Dprotobuf_MSVC_STATIC_RUNTIME:BOOL=ON - -DRE2_BUILD_TESTING:BOOL=OFF - ${_MSVC_RUNTIME_LIBRARY} -) - -# Build gRPC and protoc for host OS. -# gRPC build is needed for `grpc_plugin_cpp`. +# Build protoc for host OS. if(CMAKE_CROSSCOMPILING) - set(GRPC_HOST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/gRPC_host") - set(PROTOBUF_TARGET gRPC_host) - set(GRPC_HOST_TARGET gRPC_host) - set(gRPC_BUILD_CODEGEN OFF) - - ExternalProject_Add(gRPC_host - PREFIX ${GRPC_HOST_PREFIX} - SOURCE_DIR "${THIRDPARTY_DIR}/grpc" + set(PROTOBUF_HOST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/protobuf_host") + set(PROTOBUF_TARGET protobuf_host) + + ExternalProject_Add(protobuf_host + PREFIX ${PROTOBUF_HOST_PREFIX} + SOURCE_DIR "${THIRDPARTY_DIR}/grpc/third_party/protobuf" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= CMAKE_CACHE_ARGS - ${COMMON_GRPC_CACHE_ARGS} - ) - - set(_grpc_EXTRA_PARAM - -DgRPC_BUILD_GRPC_CPP_PLUGIN:BOOL=OFF - -DCMAKE_PROGRAM_PATH:STRING=${GRPC_HOST_PREFIX}/bin;${CMAKE_PROGRAM_PATH} + -DBUILD_TESTING:BOOL=OFF + -DCMAKE_BUILD_TYPE:STRING=Release + -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD} + -Dprotobuf_BUILD_TESTS:BOOL=OFF + -Dprotobuf_MODULE_COMPATIBLE:BOOL=ON + -Dprotobuf_INSTALL:BOOL=ON ) else() - set(GRPC_HOST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/grpc") + set(PROTOBUF_HOST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/grpc") set(PROTOBUF_TARGET grpc) - set(gRPC_BUILD_CODEGEN ON) endif() -set(PROTOBUF_HOST_PREFIX "${GRPC_HOST_PREFIX}") - if(MSVC) set(Protobuf_HOST_DIR "${PROTOBUF_HOST_PREFIX}/cmake") else() set(Protobuf_HOST_DIR "${PROTOBUF_HOST_PREFIX}/lib/cmake/protobuf") endif() -set(absl_HOST_DIR "${GRPC_HOST_PREFIX}/lib/cmake/absl") -set(utf8_range_HOST_DIR "${GRPC_HOST_PREFIX}/lib/cmake/utf8_range") +set(absl_HOST_DIR "${PROTOBUF_HOST_PREFIX}/lib/cmake/absl") +set(utf8_range_HOST_DIR "${PROTOBUF_HOST_PREFIX}/lib/cmake/utf8_range") set(PROTOBUF_HOST_INCLUDE_DIR "${PROTOBUF_HOST_PREFIX}/include") set(PROTOBUF_HOST_LIB_DIR "${PROTOBUF_HOST_PREFIX}/lib") @@ -110,17 +82,33 @@ ExternalProject_Add(grpc -DCMAKE_INSTALL_PREFIX:PATH= CMAKE_CACHE_ARGS ${_CMAKE_COMMON_CACHE_ARGS} - ${COMMON_GRPC_CACHE_ARGS} - -DgRPC_BUILD_CODEGEN:BOOL=${gRPC_BUILD_CODEGEN} + -DABSL_ENABLE_INSTALL:BOOL=ON + -DABSL_PROPAGATE_CXX_STD:BOOL=ON + -DBUILD_SHARED_LIBS:BOOL=OFF + -DBUILD_TESTING:BOOL=OFF + -Dc-ares_DIR:PATH=${_FINDPACKAGE_CARES_CONFIG_DIR} + -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD} + -DgRPC_BUILD_CODEGEN:BOOL=OFF + -DgRPC_BUILD_CSHARP_EXT:BOOL=OFF + -DgRPC_BUILD_GRPC_CPP_PLUGIN:BOOL=OFF + -DgRPC_BUILD_GRPC_CSHARP_PLUGIN:BOOL=OFF + -DgRPC_BUILD_GRPC_NODE_PLUGIN:BOOL=OFF + -DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN:BOOL=OFF + -DgRPC_BUILD_GRPC_PHP_PLUGIN:BOOL=OFF + -DgRPC_BUILD_GRPC_PYTHON_PLUGIN:BOOL=OFF + -DgRPC_BUILD_GRPC_RUBY_PLUGIN:BOOL=OFF + -DgRPC_CARES_PROVIDER:STRING=package + -DgRPC_INSTALL:BOOL=ON + -DgRPC_SSL_PROVIDER:STRING=package -DgRPC_ZLIB_PROVIDER:STRING=package + -Dprotobuf_ABSL_PROVIDER:STRING=package + -Dprotobuf_MODULE_COMPATIBLE:BOOL=ON + -Dprotobuf_MSVC_STATIC_RUNTIME:BOOL=ON + -DRE2_BUILD_TESTING:BOOL=OFF -DZLIB_ROOT:PATH=${ZLIB_ROOT} -DZLIB_USE_STATIC_LIBS:BOOL=ON - -DgRPC_SSL_PROVIDER:STRING=package - -DgRPC_CARES_PROVIDER:STRING=package - -Dc-ares_DIR:PATH=${_FINDPACKAGE_CARES_CONFIG_DIR} ${_OPENSSL_CACHE_ARGS} - ${_grpc_EXTRA_PARAM} - DEPENDS openssl ${GRPC_HOST_TARGET} zlib cares + DEPENDS openssl zlib cares ) ExternalProject_Get_Property(grpc INSTALL_DIR)