summaryrefslogtreecommitdiff
path: root/Modules/CMakeDetermineCompilerId.cmake
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2020-10-21 14:24:37 -0400
committerZack Galbreath <zack.galbreath@kitware.com>2021-06-07 19:25:33 +0000
commitff0d2858e1e47af8e849318b411b1fbd8579a053 (patch)
tree1a1eb22669fff0dafd1f8d54314e4babcf9a52f3 /Modules/CMakeDetermineCompilerId.cmake
parentbd844387df133897ce6e3f290af771acb0df4df9 (diff)
downloadcmake-ff0d2858e1e47af8e849318b411b1fbd8579a053.tar.gz
HIP: Extract clang compiler details from hipcc
Diffstat (limited to 'Modules/CMakeDetermineCompilerId.cmake')
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake35
1 files changed, 35 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index d656cd0e3c..bd1e732530 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -150,6 +150,41 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
endif()
endif()
+ # When invoked with HIPCC we need to extract the path to the underlying
+ # clang compiler when possible. This fixes the following issues:
+ # env variables can change how hipcc behaves
+ # allows us to properly find the binutils bundled with hip
+ if(CMAKE_${lang}_COMPILER_ID STREQUAL "ROCMClang"
+ AND CMAKE_${lang}_COMPILER MATCHES ".*hipcc")
+ get_filename_component(_hipcc_dir "${CMAKE_${lang}_COMPILER}" DIRECTORY)
+ execute_process(
+ COMMAND "${_hipcc_dir}/hipconfig"
+ --hipclangpath
+ OUTPUT_VARIABLE output
+ RESULT_VARIABLE result
+ )
+ if(result EQUAL 0 AND EXISTS "${output}")
+ if(lang STREQUAL "C")
+ set_property(CACHE CMAKE_${lang}_COMPILER PROPERTY VALUE "${output}/clang")
+ set(CMAKE_${lang}_COMPILER "${output}/clang" PARENT_SCOPE)
+ else()
+ set_property(CACHE CMAKE_${lang}_COMPILER PROPERTY VALUE "${output}/clang++")
+ set(CMAKE_${lang}_COMPILER "${output}/clang++" PARENT_SCOPE)
+ endif()
+ endif()
+ if(lang STREQUAL "HIP")
+ execute_process(
+ COMMAND "${_hipcc_dir}/hipconfig"
+ --rocmpath
+ OUTPUT_VARIABLE output
+ RESULT_VARIABLE result
+ )
+ if(result EQUAL 0)
+ set(_CMAKE_HIP_COMPILER_ROCM_ROOT "${output}" PARENT_SCOPE)
+ endif()
+ endif()
+ endif()
+
if (COMPILER_QNXNTO AND CMAKE_${lang}_COMPILER_ID STREQUAL "GNU")
execute_process(
COMMAND "${CMAKE_${lang}_COMPILER}"