hiprtc-config.cmake 1.05 KB
Newer Older
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
# CMake package shim for DTK hiprtc.
# DTK 26.04 ships hiprtc headers and libhiprtc.so, but not hiprtcConfig.cmake.

include(FindPackageHandleStandardArgs)

set(_hiprtc_roots)
foreach(_root IN ITEMS
    "$ENV{HIP_PATH}"
    "$ENV{ROCM_PATH}"
    "/opt/dtk/hip"
    "/opt/dtk")
  if(_root AND EXISTS "${_root}")
    list(APPEND _hiprtc_roots "${_root}")
  endif()
endforeach()

find_path(hiprtc_INCLUDE_DIR
  NAMES hip/hiprtc.h
  HINTS ${_hiprtc_roots}
  PATH_SUFFIXES include hip/include
)

find_library(hiprtc_LIBRARY
  NAMES hiprtc
  HINTS ${_hiprtc_roots}
  PATH_SUFFIXES lib lib64 hip/lib hip/lib64
)

find_package_handle_standard_args(hiprtc
  REQUIRED_VARS hiprtc_INCLUDE_DIR hiprtc_LIBRARY
)

if(hiprtc_FOUND)
  set(hiprtc_INCLUDE_DIRS "${hiprtc_INCLUDE_DIR}")
  set(hiprtc_LIBRARIES "${hiprtc_LIBRARY}")

  if(NOT TARGET hiprtc::hiprtc)
    add_library(hiprtc::hiprtc SHARED IMPORTED)
    set_target_properties(hiprtc::hiprtc PROPERTIES
      IMPORTED_LOCATION "${hiprtc_LIBRARY}"
      INTERFACE_INCLUDE_DIRECTORIES "${hiprtc_INCLUDE_DIR}"
    )
  endif()
endif()