diff --git a/cmake-linux/grpc.cmake b/cmake-linux/grpc.cmake index 2c37e67..56d9bd5 100644 --- a/cmake-linux/grpc.cmake +++ b/cmake-linux/grpc.cmake @@ -2,7 +2,7 @@ set(grpc_build_dir "${LIB_BASE_DIR}/grpc-build") -if(NOT EXISTS ${grpc_build_dir}/111) +if(NOT EXISTS ${grpc_build_dir}) # install grpc execute_process(COMMAND mkdir -p ${grpc_build_dir}) message(STATUS "${BoldGreen}Install grpc third party library") @@ -30,7 +30,10 @@ if(NOT EXISTS ${grpc_build_dir}/111) COMMAND cmake --install . WORKING_DIRECTORY ${grpc_build_dir}) execute_process(COMMAND cp -rf ${LIB_BASE_DIR}/grpc-src/third_party/abseil-cpp/absl ${grpc_build_dir}/include) - execute_process(COMMAND cp -f ${CMAKE_CURRENT_SOURCE_DIR}/patch/grpc/* ${grpc_build_dir}) + execute_process( + COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/patch/grpc ${LIB_BASE_DIR}/grpc-build + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) message("${BoldGreen}GRPC Installed !${ColourReset}") endif() @@ -39,9 +42,7 @@ set(gRPC_DIR ${grpc_build_dir}) find_package(Threads REQUIRED) find_package(protobuf REQUIRED) find_package(gRPC CONFIG REQUIRED) -message(${BoldGreen} - _IMPORT_PREFIX:${_IMPORT_PREFIX} \n - gRPC_LIBRARIES:${gRPC_LIBRARIES}${ColourReset}) + include_directories(${grpc_build_dir}/include) link_directories(${grpc_build_dir}/lib) # local proto file @@ -53,5 +54,5 @@ message(${BoldGreen} proto_file: ${grpc_BINARY_DIR}/protoc \n grpc_cpp_plugin:${grpc_BINARY_DIR}/grpc_cpp_plugin${ColourReset}) -list(APPEND third_party_libraries grpc++ grpc++_reflection protobuf) +list(APPEND third_party_libraries gRPC::grpc++ gRPC::grpc++_reflection protobuf) diff --git a/grpc/CMakeLists.txt b/grpc/CMakeLists.txt index 2a152dd..1c5308e 100644 --- a/grpc/CMakeLists.txt +++ b/grpc/CMakeLists.txt @@ -5,7 +5,7 @@ add_custom_command( ${PROTO_DIR}/wenet.pb.h ${PROTO_DIR}/wenet.grpc.pb.cc ${PROTO_DIR}/wenet.grpc.pb.h - COMMAND ${protobuf_BINARY_DIR}/protoc + COMMAND ${grpc_BINARY_DIR}/protoc ARGS --grpc_out "${PROTO_DIR}" --cpp_out "${PROTO_DIR}" -I "${PROTO_DIR}" @@ -14,10 +14,11 @@ add_custom_command( # grpc_server/client link_directories(${protobuf_BINARY_DIR}/lib) + add_library(wenet_grpc STATIC grpc_client.cc grpc_server.cc wenet.pb.cc wenet.grpc.pb.cc ) -target_link_libraries(wenet_grpc PUBLIC grpc++ grpc++_reflection decoder) +target_link_libraries(wenet_grpc PUBLIC ${third_party_libraries} decoder) diff --git a/patch/grpc/gRPCTargets.cmake b/patch/grpc/gRPCTargets.cmake index 49e9f93..ce2960b 100644 --- a/patch/grpc/gRPCTargets.cmake +++ b/patch/grpc/gRPCTargets.cmake @@ -39,7 +39,7 @@ endif() unset(_targetsDefined) unset(_targetsNotDefined) unset(_expectedTargets) - +set(_IMPORT_PREFIX ${grpc_build_dir}) message("${BoldGreen}GRPC _IMPORT_PREFIX:${_IMPORT_PREFIX}${ColourReset}") # Compute the installation prefix relative to this file. get_filename_component(_IMPORT_PREFIX "gRPCTargets.cmake" PATH)