summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCompilerId.cmake
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2020-10-21 18:24:37 (GMT)
committerZack Galbreath <zack.galbreath@kitware.com>2021-06-07 19:25:33 (GMT)
commitff0d2858e1e47af8e849318b411b1fbd8579a053 (patch)
tree1a1eb22669fff0dafd1f8d54314e4babcf9a52f3 /Modules/CMakeDetermineCompilerId.cmake
parentbd844387df133897ce6e3f290af771acb0df4df9 (diff)
downloadCMake-ff0d2858e1e47af8e849318b411b1fbd8579a053.zip
CMake-ff0d2858e1e47af8e849318b411b1fbd8579a053.tar.gz
CMake-ff0d2858e1e47af8e849318b411b1fbd8579a053.tar.bz2
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 d656cd0..bd1e732 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}"