# On how to build grpc, you may refer to https://github.com/grpc/grpc set(grpc_build_dir "${LIB_BASE_DIR}/grpc-build") if(NOT EXISTS ${grpc_build_dir}) # install grpc execute_process(COMMAND mkdir -p ${grpc_build_dir}) message(STATUS "${BoldGreen}Install grpc third party library") execute_process( COMMAND cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=${grpc_build_dir} -S ${LIB_BASE_DIR}/grpc-src -B ${grpc_build_dir} WORKING_DIRECTORY ${grpc_build_dir}) execute_process( COMMAND cmake --build . -j4 WORKING_DIRECTORY ${grpc_build_dir}) execute_process( COMMAND cmake --install . -j6 WORKING_DIRECTORY ${grpc_build_dir}) execute_process( COMMAND cp -r ${LIB_BASE_DIR}/grpc-src/third_party/abseil-cpp/absl ${grpc_build_dir}/include) message("${BoldGreen}GRPC Installed !${ColourReset}") endif() FetchContent_Declare(grpc SOURCE_DIR ${LIB_BASE_DIR}/grpc-src) FetchContent_MakeAvailable(grpc) include_directories(${grpc_build_dir}/include) # local proto file set(PROTO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bin_grpc") set(grpc_BINARY_DIR "${grpc_build_dir}/bin") message(${BoldGreen} protoc:${protobuf_BINARY_DIR}/protoc \n grpc_cpp_plugin:${grpc_BINARY_DIR}/grpc_cpp_plugin\n helloworld:${PROTO_DIR}/helloworld.proto${ColourReset}) list(APPEND third_party_libraries grpc++ grpc++_reflection libprotobuf)