File: cccl-config.cmake

package info (click to toggle)
nvidia-cuda-toolkit 12.4.1-2
  • links: PTS, VCS
  • area: non-free
  • in suites: trixie
  • size: 18,505,836 kB
  • sloc: ansic: 203,477; cpp: 64,769; python: 34,699; javascript: 22,006; xml: 13,410; makefile: 3,085; sh: 2,343; perl: 352
file content (103 lines) | stat: -rw-r--r-- 3,680 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#
# find_package(CCCL) config file.
#
# Imports the Thrust, CUB, and libcudacxx components of the NVIDIA
# CUDA/C++ Core Libraries.

set(cccl_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")

if (${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
  set(cccl_quiet_flag "QUIET")
else()
  set(cccl_quiet_flag "")
endif()

if (DEFINED ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS AND
    ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
  set(components ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS})
else()
  set(components Thrust CUB libcudacxx)
endif()

if (NOT TARGET CCCL::CCCL)
  add_library(CCCL::CCCL INTERFACE IMPORTED GLOBAL)
endif()

foreach(component IN LISTS components)
  string(TOLOWER "${component}" component_lower)

  unset(req)
  if (${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED_${component})
    set(cccl_comp_required_flag "REQUIRED")
  endif()

  if(component_lower STREQUAL "libcudacxx")
    find_package(libcudacxx ${CCCL_VERSION} EXACT CONFIG
      ${cccl_quiet_flag}
      ${cccl_comp_required_flag}
      NO_DEFAULT_PATH # Only check the explicit HINTS below:
      HINTS
        "${cccl_cmake_dir}/../../../libcudacxx/lib/cmake/" # Source layout (GitHub)
        "${cccl_cmake_dir}/.."                             # Install layout
    )
    # Can't alias other alias targets, so use the uglified target name instead
    # of libcudacxx::libcudacxx:
    if (TARGET _libcudacxx_libcudacxx AND NOT TARGET CCCL::libcudacxx)
      add_library(CCCL::libcudacxx ALIAS _libcudacxx_libcudacxx)
      target_link_libraries(CCCL::CCCL INTERFACE CCCL::libcudacxx)
    endif()
  elseif(component_lower STREQUAL "cub")
    find_package(CUB ${CCCL_VERSION} EXACT CONFIG
      ${cccl_quiet_flag}
      ${cccl_comp_required_flag}
      NO_DEFAULT_PATH # Only check the explicit HINTS below:
      HINTS
        "${cccl_cmake_dir}/../../../cub/cub/cmake/" # Source layout (GitHub)
        "${cccl_cmake_dir}/.."                      # Install layout
    )
    # Can't alias other alias targets, so use the uglified target name instead
    # of CUB::CUB:
    if (TARGET _CUB_CUB AND NOT TARGET CCCL::CUB)
      add_library(CCCL::CUB ALIAS _CUB_CUB)
      target_link_libraries(CCCL::CCCL INTERFACE CCCL::CUB)
    endif()
  elseif(component_lower STREQUAL "thrust")
    find_package(Thrust ${CCCL_VERSION} EXACT CONFIG
      ${cccl_quiet_flag}
      ${cccl_comp_required_flag}
      NO_DEFAULT_PATH # Only check the explicit HINTS below:
      HINTS
        "${cccl_cmake_dir}/../../../thrust/thrust/cmake/" # Source layout (GitHub)
        "${cccl_cmake_dir}/.."                            # Install layout
    )

    if (TARGET Thrust::Thrust AND NOT TARGET CCCL::Thrust)
      # By default, configure a CCCL::Thrust target with host=cpp device=cuda
      option(CCCL_ENABLE_DEFAULT_THRUST_TARGET
        "Create a CCCL::Thrust target using CCCL_THRUST_[HOST|DEVICE]_SYSTEM."
        ON
      )
      mark_as_advanced(CCCL_ENABLE_DEFAULT_THRUST_TARGET)
      if (CCCL_ENABLE_DEFAULT_THRUST_TARGET)
        thrust_create_target(CCCL::Thrust FROM_OPTIONS
          HOST_OPTION CCCL_THRUST_HOST_SYSTEM
          DEVICE_OPTION CCCL_THRUST_DEVICE_SYSTEM
          HOST_OPTION_DOC
            "Host system for CCCL::Thrust target."
          DEVICE_OPTION_DOC
            "Device system for CCCL::Thrust target."
          ADVANCED
        )
        target_link_libraries(CCCL::CCCL INTERFACE CCCL::Thrust)
      endif()
    endif()
  else()
    message(FATAL_ERROR "Invalid CCCL component requested: '${component}'")
  endif()
endforeach()

include(FindPackageHandleStandardArgs)
if (NOT CCCL_CONFIG)
  set(CCCL_CONFIG "${CMAKE_CURRENT_LIST_FILE}")
endif()
find_package_handle_standard_args(CCCL CONFIG_MODE)