1 cmake_minimum_required(VERSION 3.22.1)
 2 project(cuda_backend)
 3 
 4 set(CMAKE_CXX_STANDARD 14)
 5 
 6 # this is the only way I can think of to get cmake to find FindHIP.cmake
 7 set(ROCM_PATH "/opt/rocm")
 8 list(APPEND CMAKE_MODULE_PATH "${ROCM_PATH}/lib/cmake/hip")
 9 # /opt/rocm-6.3.4/lib/cmake/hip/FindHIP.cmake
10 # Weirdly the above does not set HIP_INCLUDE_DIR
11 # This seems to set expected VARS but is not 
12 # invoked  /opt/rocm-6.3.4/lib/cmake/hip/hip-config.cmake
13 find_package(HIP)
14 get_cmake_property(_variableNames VARIABLES)
15 foreach (_variableName ${_variableNames})
16     message(STATUS "${_variableName}=${${_variableName}}")
17 endforeach()
18 if(HIP_FOUND)
19    if(HIP_READY) #  get rid of this once we figur out how to build
20     set(HIP_INCLUDE_DIR "/opt/rocm/include")
21     if ("${HIP_BACKEND}EMPTY" STREQUAL "EMPTY")
22       set (HIP_BACKEND "${CMAKE_SOURCE_DIR}")
23       message("HIP_BACKEND=${HIP_BACKEND}")
24     endif()
25 
26     if ("${SHARED_BACKEND}EMPTY" STREQUAL "EMPTY")
27         set (SHARED_BACKEND "${CMAKE_SOURCE_DIR}/../shared")
28         message("SHARED_BACKEND=${SHARED_BACKEND}")
29     endif()
30 
31     include_directories(
32        ${HIP_INCLUDE_DIR}
33        ${SHARED_BACKEND}/include
34        ${HIP_BACKEND}/include
35     )
36 
37     link_directories(
38        ${CMAKE_BINARY_DIR}
39        ${hip_LIB_INSTALL_DIR}
40     )
41 
42     add_library(hip_backend SHARED
43        ${SHARED_BACKEND}/cpp/shared.cpp
44        ${HIP_BACKEND}/cpp/hip_backend.cpp
45     )
46 
47     #target_link_libraries(hip_backend
48     #   PRIVATE hip::host
49     #)
50 
51     add_executable(hip_info
52        ${HIP_BACKEND}/cpp/info.cpp
53     )
54 
55     target_link_libraries(hip_info
56        hip_backend
57      #  hip::host
58     )
59   else()
60      message("FOUND HIP but CMakefile still broken")
61   endif()
62 endif()