You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.5 KiB

  1. # On how to build grpc, you may refer to https://github.com/grpc/grpc
  2. set(grpc_build_dir "${LIB_BASE_DIR}/grpc-build")
  3. if(NOT EXISTS ${grpc_build_dir})
  4. # install grpc
  5. execute_process(COMMAND mkdir -p ${grpc_build_dir})
  6. message(STATUS "${BoldGreen}Install grpc third party library")
  7. execute_process(
  8. COMMAND cmake
  9. -DgRPC_INSTALL=ON
  10. -DgRPC_BUILD_TESTS=OFF
  11. -DCMAKE_INSTALL_PREFIX=${grpc_build_dir}
  12. -S ${LIB_BASE_DIR}/grpc-src
  13. -B ${grpc_build_dir}
  14. WORKING_DIRECTORY ${grpc_build_dir})
  15. execute_process(
  16. COMMAND cmake --build . -j4
  17. WORKING_DIRECTORY ${grpc_build_dir})
  18. execute_process(
  19. COMMAND cmake --install . -j6
  20. WORKING_DIRECTORY ${grpc_build_dir})
  21. execute_process(
  22. COMMAND cp -r ${LIB_BASE_DIR}/grpc-src/third_party/abseil-cpp/absl ${grpc_build_dir}/include)
  23. message("${BoldGreen}GRPC Installed !${ColourReset}")
  24. endif()
  25. FetchContent_Declare(grpc
  26. SOURCE_DIR ${LIB_BASE_DIR}/grpc-src)
  27. FetchContent_MakeAvailable(grpc)
  28. include_directories(${grpc_build_dir}/include)
  29. # local proto file
  30. set(PROTO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bin_grpc")
  31. set(grpc_BINARY_DIR "${grpc_build_dir}/bin")
  32. message(${BoldGreen}
  33. protoc${protobuf_BINARY_DIR}/protoc \n
  34. grpc_cpp_plugin${grpc_BINARY_DIR}/grpc_cpp_plugin\n
  35. helloworld${PROTO_DIR}/helloworld.proto${ColourReset})
  36. list(APPEND third_party_libraries grpc++ grpc++_reflection libprotobuf)