summaryrefslogtreecommitdiff
path: root/Modules/CMakeDetermineHIPCompiler.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-09-16 13:36:40 -0400
committerBrad King <brad.king@kitware.com>2021-09-16 14:45:07 -0400
commitb125e9809a1a3f3e28fc1682c8a33c3a928f79b5 (patch)
tree28ca771d0e701fbbd23991cfe03a97c1835686c0 /Modules/CMakeDetermineHIPCompiler.cmake
parent735f41fc2d91bac11506ebf355136b0dbd8ac8c7 (diff)
downloadcmake-b125e9809a1a3f3e28fc1682c8a33c3a928f79b5.tar.gz
HIP: Detect ROCm path earlier
Fail early if it is not found. Use the detected location as a hint to find `rocm_agent_enumerator`. Also remove the leading `_` prefix in case we want to document this publicly later.
Diffstat (limited to 'Modules/CMakeDetermineHIPCompiler.cmake')
-rw-r--r--Modules/CMakeDetermineHIPCompiler.cmake14
1 files changed, 14 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineHIPCompiler.cmake b/Modules/CMakeDetermineHIPCompiler.cmake
index 4f0b75445b..394f8e2be0 100644
--- a/Modules/CMakeDetermineHIPCompiler.cmake
+++ b/Modules/CMakeDetermineHIPCompiler.cmake
@@ -52,7 +52,20 @@ if(NOT CMAKE_HIP_COMPILER_ID_RUN)
CMAKE_DETERMINE_COMPILER_ID(HIP HIPFLAGS CMakeHIPCompilerId.hip)
_cmake_find_compiler_sysroot(HIP)
+endif()
+if(NOT CMAKE_HIP_COMPILER_ROCM_ROOT)
+ execute_process(
+ COMMAND hipconfig --rocmpath
+ OUTPUT_VARIABLE _CMAKE_HIPCONFIG_ROCMPATH
+ RESULT_VARIABLE _CMAKE_HIPCONFIG_RESULT
+ )
+ if(_CMAKE_HIPCONFIG_RESULT EQUAL 0 AND EXISTS "${_CMAKE_HIPCONFIG_ROCMPATH}")
+ set(CMAKE_HIP_COMPILER_ROCM_ROOT "${_CMAKE_HIPCONFIG_ROCMPATH}")
+ endif()
+endif()
+if(NOT CMAKE_HIP_COMPILER_ROCM_ROOT)
+ message(FATAL_ERROR "Failed to find ROCm root directory.")
endif()
if (NOT _CMAKE_TOOLCHAIN_LOCATION)
@@ -89,6 +102,7 @@ if(NOT DEFINED CMAKE_HIP_ARCHITECTURES)
set(_CMAKE_HIP_ARCHITECTURES)
find_program(_CMAKE_HIP_ROCM_AGENT_ENUMERATOR
NAMES rocm_agent_enumerator
+ HINTS "${CMAKE_HIP_COMPILER_ROCM_ROOT}/bin"
NO_CACHE)
if(_CMAKE_HIP_ROCM_AGENT_ENUMERATOR)
execute_process(COMMAND "${_CMAKE_HIP_ROCM_AGENT_ENUMERATOR}" -t GPU