Supporting cases where rocm-cmake is not installed

This commit is contained in:
Dr-Noob
2025-10-15 08:39:24 +02:00
parent 5df85aea2c
commit 62e358a017

View File

@@ -27,7 +27,6 @@ if(ENABLE_CUDA_BACKEND)
endif()
if(ENABLE_HSA_BACKEND)
# TODO: Needs rocm-cmake, what if its not insalled?
find_package(ROCmCMakeBuildTools)
if (ROCmCMakeBuildTools_FOUND)
find_package(hsa-runtime64 1.0 REQUIRED)
@@ -48,11 +47,23 @@ if(ENABLE_HSA_BACKEND)
message(STATUS "${BoldYellow}HSA not found, disabling HSA backend${ColorReset}")
set(ENABLE_HSA_BACKEND false)
endif()
else()
# rocm-cmake is not installed, try to manually find neccesary files.
if (NOT DEFINED ROCM_PATH)
set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to ROCm")
endif()
find_path(HSA_INCLUDE_DIR hsa/hsa.h HINTS ${ROCM_PATH}/include)
find_library(HSA_LIBRARY hsa-runtime64 HINTS ${ROCM_PATH}/lib ${ROCM_PATH}/lib64)
if (HSA_INCLUDE_DIR and HSA_LIBRARY)
message(STATUS "${BoldYellow}Found ROCm manually${ColorReset}")
else()
set(ENABLE_HSA_BACKEND false)
message(STATUS "${BoldYellow}ROCm not found${ColorReset}")
endif()
endif()
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
find_package(PCIUTILS)
@@ -136,7 +147,7 @@ if(ENABLE_HSA_BACKEND)
target_include_directories(hsa_backend PRIVATE "${HSA_INCLUDE_DIR}")
message(STATUS "Found HSA: ${HSA_INCLUDE_DIR}")
target_link_libraries(hsa_backend PRIVATE hsa-runtime64::hsa-runtime64)
target_link_libraries(hsa_backend PRIVATE ${HSA_LIBRARY})
target_link_libraries(gpufetch hsa_backend)
endif()