# find grpc, 测试对 grpc v1.23.x 有效，可以找到所有的动态库
message("researching for grpc v1.23.x")
set(GRPC_ROOT "${gRPC_ROOT}")
set(GRPC_FOUND 1)
set(gRPC_INCLUDE_DIR  ${GRPC_ROOT}/include)
set(gRPC_INCLUDE_DIRS ${GRPC_ROOT}/include)

# .so
find_library(gRPC_ADDRESS_SORTING_LIBRARY_SHARED      address_sorting ${GRPC_ROOT}/lib NO_DEFAULT_PATH)
find_library(gRPC_GPR_LIBRARY_SHARED                  gpr ${GRPC_ROOT}/lib NO_DEFAULT_PATH)
find_library(gRPC_GRPC++_LIBRARY_SHARED               grpc++ ${GRPC_ROOT}/lib NO_DEFAULT_PATH)
find_library(gRPC_GRPC++_ERROR_DETAILS_LIBRARY_SHARED grpc++_error_details ${GRPC_ROOT}/lib NO_DEFAULT_PATH)
find_library(gRPC_GRPC++_REFLECTION_LIBRARY_SHARED    grpc++_reflection ${GRPC_ROOT}/lib NO_DEFAULT_PATH)
find_library(gRPC_GRPC++_UNSECURE_LIBRARY_SHARED      grpc++_unsecure ${GRPC_ROOT}/lib NO_DEFAULT_PATH)
find_library(gRPC_GRPC_LIBRARY_SHARED                 grpc ${GRPC_ROOT}/lib NO_DEFAULT_PATH)
find_library(gRPC_GRPCPP_CHANNELZ_LIBRARY_SHARED      grpcpp_channelz ${GRPC_ROOT}/lib NO_DEFAULT_PATH)
find_library(gRPC_GRPC_CRONET_LIBRARY_SHARED          grpc_cronet ${GRPC_ROOT}/lib NO_DEFAULT_PATH)
find_library(gRPC_GRPC_UNSECURE_LIBRARY_SHARED        grpc_unsecure ${GRPC_ROOT}/lib NO_DEFAULT_PATH)

message(STATUS "gRPC_ADDRESS_SORTING_LIBRARY_SHARED     : " ${gRPC_ADDRESS_SORTING_LIBRARY_SHARED})
message(STATUS "gRPC_GPR_LIBRARY_SHARED                 : " ${gRPC_GPR_LIBRARY_SHARED})
message(STATUS "gRPC_GRPC++_LIBRARY_SHARED              : " ${gRPC_GRPC++_LIBRARY_SHARED})
message(STATUS "gRPC_GRPC++_ERROR_DETAILS_LIBRARY_SHARED: " ${gRPC_GRPC++_ERROR_DETAILS_LIBRARY_SHARED})
message(STATUS "gRPC_GRPC++_REFLECTION_LIBRARY_SHARED   : " ${gRPC_GRPC++_REFLECTION_LIBRARY_SHARED})
message(STATUS "gRPC_GRPC++_UNSECURE_LIBRARY_SHARED     : " ${gRPC_GRPC++_UNSECURE_LIBRARY_SHARED})
message(STATUS "gRPC_GRPC_LIBRARY_SHARED                : " ${gRPC_GRPC_LIBRARY_SHARED})
message(STATUS "gRPC_GRPCPP_CHANNELZ_LIBRARY_SHARED     : " ${gRPC_GRPCPP_CHANNELZ_LIBRARY_SHARED})
message(STATUS "gRPC_GRPC_CRONET_LIBRARY_SHARED         : " ${gRPC_GRPC_CRONET_LIBRARY_SHARED})
message(STATUS "gRPC_GRPC_UNSECURE_LIBRARY_SHARED       : " ${gRPC_GRPC_UNSECURE_LIBRARY_SHARED})

# plugin
find_program(gRPC_CPP_PLUGIN_EXECUTABLE NAMES grpc_cpp_plugin PATHS ${GRPC_ROOT}/bin NO_DEFAULT_PATH)
message(STATUS "gRPC_CPP_PLUGIN_EXECUTABLE : " ${gRPC_CPP_PLUGIN_EXECUTABLE})

foreach (Camel
        gRPC_INCLUDE_DIR
        gRPC_INCLUDE_DIRS
        gRPC_ADDRESS_SORTING_LIBRARY_SHARED
        gRPC_GPR_LIBRARY_SHARED
        gRPC_GRPC++_LIBRARY_SHARED
        gRPC_GRPC++_ERROR_DETAILS_LIBRARY_SHARED
        gRPC_GRPC++_REFLECTION_LIBRARY_SHARED
        gRPC_GRPC++_UNSECURE_LIBRARY_SHARED
        gRPC_GRPC_LIBRARY_SHARED
        gRPC_GRPCPP_CHANNELZ_LIBRARY_SHARED
        gRPC_GRPC_CRONET_LIBRARY_SHARED
        gRPC_GRPC_UNSECURE_LIBRARY_SHARED
        gRPC_CPP_PLUGIN_EXECUTABLE
        )
    string(TOUPPER ${Camel} UPPER)
    set(${UPPER} ${${Camel}})
endforeach ()