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

CMakeLists.txt 3.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. find_package(Threads REQUIRED)
  2. # This branch assumes that gRPC and all its dependencies are already installed
  3. # on this system, so they can be located by find_package().
  4. # Find Protobuf installation
  5. # Looks for protobuf-config.cmake file installed by Protobuf's cmake installation.
  6. #set(protobuf_MODULE_COMPATIBLE TRUE)
  7. #find_package(Protobuf CONFIG REQUIRED)
  8. #message(STATUS "Using protobuf ${protobuf_VERSION}")
  9. add_library(protobuf::libprotobuf ALIAS protobuf::protobuf)
  10. add_executable(protobuf::libprotoc ALIAS protobuf::protoc)
  11. set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
  12. if (CMAKE_CROSSCOMPILING)
  13. find_program(_PROTOBUF_PROTOC protoc)
  14. else ()
  15. set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
  16. endif ()
  17. # Find gRPC installation
  18. # Looks for gRPCConfig.cmake file installed by gRPC's cmake installation.
  19. if (EXISTS ${grpc_ROOT}/lib64)
  20. set(gRPC_DIR "${grpc_ROOT}/lib64/cmake/grpc")
  21. else ()
  22. set(gRPC_DIR "${grpc_ROOT}/lib/cmake/grpc")
  23. endif ()
  24. message("serving ut using grpc_DIR : " ${gPRC_DIR})
  25. find_package(gRPC CONFIG REQUIRED)
  26. message(STATUS "Using gRPC ${gRPC_VERSION}")
  27. set(_GRPC_GRPCPP gRPC::grpc++)
  28. set(_REFLECTION gRPC::grpc++_reflection)
  29. if (CMAKE_CROSSCOMPILING)
  30. find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
  31. find_program(_GRPC_PYTHON_PLUGIN_EXECUTABLE grpc_python_plugin)
  32. else ()
  33. set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
  34. set(_GRPC_PYTHON_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_python_plugin>)
  35. endif ()
  36. # Proto file
  37. get_filename_component(hw_proto "ms_service.proto" ABSOLUTE)
  38. get_filename_component(hw_proto_path ${hw_proto} PATH)
  39. # Generated sources
  40. set(hw_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/ms_service.pb.cc")
  41. set(hw_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/ms_service.pb.h")
  42. set(hw_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/ms_service.grpc.pb.cc")
  43. set(hw_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/ms_service.grpc.pb.h")
  44. set(hw_py_pb2 "${CMAKE_CURRENT_BINARY_DIR}/ms_service_pb2.py")
  45. set(hw_py_pb2_grpc "${CMAKE_CURRENT_BINARY_DIR}/ms_service_pb2_grpc.py")
  46. add_custom_command(
  47. OUTPUT "${hw_proto_srcs}" "${hw_proto_hdrs}" "${hw_grpc_srcs}" "${hw_grpc_hdrs}" "${hw_py_pb2}" "${hw_py_pb2_grpc}"
  48. COMMAND ${_PROTOBUF_PROTOC}
  49. ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
  50. --cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
  51. -I "${hw_proto_path}"
  52. --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
  53. "${hw_proto}"
  54. COMMAND ${_PROTOBUF_PROTOC}
  55. ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
  56. --python_out "${CMAKE_CURRENT_BINARY_DIR}"
  57. -I "${hw_proto_path}"
  58. --plugin=protoc-gen-grpc="${_GRPC_PYTHON_PLUGIN_EXECUTABLE}"
  59. "${hw_proto}"
  60. DEPENDS "${hw_proto}")
  61. list(APPEND SERVING_SRC_TEST ${hw_proto_srcs} ${hw_grpc_srcs})
  62. file(GLOB_RECURSE ACL_SESSION_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
  63. "../../../../serving/acl/*.cc"
  64. "../../../../serving/core/*.cc")
  65. list(APPEND SERVING_SRC_TEST ${ACL_SESSION_SRC_LIST})
  66. # utest files
  67. file(GLOB_RECURSE ACL_UTEST_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc")
  68. list(APPEND SERVING_SRC_TEST ${ACL_UTEST_SRC_LIST})
  69. include_directories(${CMAKE_SOURCE_DIR}/serving/core)
  70. include_directories(${CMAKE_SOURCE_DIR}/serving/acl)
  71. include_directories(${CMAKE_SOURCE_DIR}/serving)
  72. include_directories(${CMAKE_CURRENT_SOURCE_DIR})
  73. include_directories(${CMAKE_CURRENT_BINARY_DIR})
  74. include_directories(${CMAKE_CURRENT_BINARY_DIR}/../)
  75. add_library(_ut_serving_obj OBJECT ${SERVING_SRC_TEST})