xref: /aosp_15_r20/external/pytorch/cmake/Modules/FindGloo.cmake (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1# Try to find the Gloo library and headers.
2#  Gloo_FOUND        - system has Gloo lib
3#  Gloo_INCLUDE_DIRS - the Gloo include directory
4#  Gloo_LIBRARY/Gloo_NATIVE_LIBRARY    - libraries needed to use Gloo
5
6find_path(Gloo_INCLUDE_DIR
7  NAMES gloo/common/common.h
8  DOC "The directory where Gloo includes reside"
9)
10
11find_library(Gloo_NATIVE_LIBRARY
12  NAMES gloo
13  DOC "The Gloo library (without CUDA)"
14)
15
16find_library(Gloo_CUDA_LIBRARY
17  NAMES gloo_cuda
18  DOC "The Gloo library (with CUDA)"
19)
20
21set(Gloo_INCLUDE_DIRS ${Gloo_INCLUDE_DIR})
22
23# use the CUDA library depending on the Gloo_USE_CUDA variable
24if (DEFINED Gloo_USE_CUDA)
25  if (${Gloo_USE_CUDA})
26    set(Gloo_LIBRARY ${Gloo_CUDA_LIBRARY})
27    set(Gloo_NATIVE_LIBRARY ${Gloo_NATIVE_LIBRARY})
28  else()
29    set(Gloo_LIBRARY ${Gloo_NATIVE_LIBRARY})
30    set(Gloo_NATIVE_LIBRARY ${Gloo_NATIVE_LIBRARY})
31  endif()
32else()
33  # else try to use the CUDA library if found
34  if (${Gloo_CUDA_LIBRARY} STREQUAL "Gloo_CUDA_LIBRARY-NOTFOUND")
35    set(Gloo_LIBRARY ${Gloo_NATIVE_LIBRARY})
36    set(Gloo_NATIVE_LIBRARY ${Gloo_NATIVE_LIBRARY})
37  else()
38    set(Gloo_LIBRARY ${Gloo_CUDA_LIBRARY})
39    set(Gloo_NATIVE_LIBRARY ${Gloo_NATIVE_LIBRARY})
40  endif()
41endif()
42
43include(FindPackageHandleStandardArgs)
44find_package_handle_standard_args(Gloo
45  FOUND_VAR Gloo_FOUND
46  REQUIRED_VARS Gloo_INCLUDE_DIR Gloo_LIBRARY
47)
48
49mark_as_advanced(Gloo_FOUND)
50