cc_library(
  processgroup
  SRCS ProcessGroup.cc
  DEPS phi_api eager_api)
cc_library(
  eager_reducer
  SRCS reducer.cc
  DEPS eager_api processgroup phi_api string_helper)

if(WITH_DISTRIBUTE)
  cc_library(
    processgroup_gloo
    SRCS ProcessGroupGloo.cc
    DEPS phi_api eager_api gloo_wrapper)
endif()

if(WITH_NCCL OR WITH_RCCL)
  cc_library(
    processgroup_nccl
    SRCS ProcessGroupNCCL.cc NCCLTools.cc Common.cc
    DEPS place enforce collective_helper device_context phi_api eager_api)
  if(WITH_DISTRIBUTE AND WITH_PSCORE)
    cc_library(
      processgroup_heter
      SRCS ProcessGroupHeter.cc NCCLTools.cc Common.cc
      DEPS place enforce collective_helper device_context phi_api eager_api)
  endif()
endif()

if(WITH_ASCEND_CL)
  cc_library(
    processgroup_hccl
    SRCS ProcessGroupHCCL.cc HCCLTools.cc Common.cc
    DEPS place
         npu_stream
         enforce
         collective_helper
         device_context
         phi_api
         eager_api)
  if(WITH_DISTRIBUTE AND WITH_PSCORE)
    cc_library(
      processgroup_heter
      SRCS ProcessGroupHeter.cc HCCLTools.cc Common.cc
      DEPS place
           npu_stream
           enforce
           collective_helper
           device_context
           phi_api
           eager_api)
  endif()
endif()

if(WITH_CUSTOM_DEVICE)
  cc_library(
    processgroup_custom
    SRCS ProcessGroupCustom.cc CustomCCLTools.cc Common.cc
    DEPS phi_backends
         place
         enforce
         collective_helper
         device_context
         phi_api
         eager_api)
endif()