summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-01-05 15:16:42 (GMT)
committerKitware Robot <kwrobot@kitware.com>2024-01-05 15:16:53 (GMT)
commit769be838cb9c952e6f3d4e3030dea291e542d69a (patch)
treea8de9803caa0ecbb2970b26490c32402e4312375 /Modules
parent159872ab8bbb06f671ea3d976e8cd3f2e350bd55 (diff)
parentce9c6d0994799a64d1cea4eac0492d27ded74b75 (diff)
downloadCMake-769be838cb9c952e6f3d4e3030dea291e542d69a.zip
CMake-769be838cb9c952e6f3d4e3030dea291e542d69a.tar.gz
CMake-769be838cb9c952e6f3d4e3030dea291e542d69a.tar.bz2
Merge topic 'check_language_propagate_hip_platform'
ce9c6d0994 HIP: Propagate CMAKE_HIP_PLATFORM from/to the test project in check_language 9ba3fc91e5 HIP: Really forward CMAKE_HIP_HOST_COMPILER in check_language(HIP) Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !9121
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CheckLanguage.cmake28
1 files changed, 26 insertions, 2 deletions
diff --git a/Modules/CheckLanguage.cmake b/Modules/CheckLanguage.cmake
index 94948b9..bad3590 100644
--- a/Modules/CheckLanguage.cmake
+++ b/Modules/CheckLanguage.cmake
@@ -41,6 +41,12 @@ or :command:`project` commands:
not be set without also setting
:variable:`CMAKE_<LANG>_COMPILER` to a NVCC compiler.
+ :variable:`CMAKE_<LANG>_PLATFORM <CMAKE_HIP_PLATFORM>`
+ This variable is set to the detected GPU platform when ``<lang>`` is ``HIP``.
+
+ If the variable is already set its value is always preserved. Only compatible values
+ will be considered for :variable:`CMAKE_<LANG>_COMPILER`.
+
For example:
.. code-block:: cmake
@@ -66,15 +72,23 @@ macro(check_language lang)
set(extra_compiler_variables)
if("${lang}" MATCHES "^(CUDA|HIP)$" AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
- set(extra_compiler_variables "set(CMAKE_CUDA_HOST_COMPILER \\\"\${CMAKE_CUDA_HOST_COMPILER}\\\")")
+ set(extra_compiler_variables "set(CMAKE_${lang}_HOST_COMPILER \\\"\${CMAKE_${lang}_HOST_COMPILER}\\\")")
+ endif()
+
+ if("${lang}" STREQUAL "HIP")
+ list(APPEND extra_compiler_variables "set(CMAKE_${lang}_PLATFORM \\\"\${CMAKE_${lang}_PLATFORM}\\\")")
endif()
+ list(TRANSFORM extra_compiler_variables PREPEND "\"")
+ list(TRANSFORM extra_compiler_variables APPEND "\\n\"")
+ list(JOIN extra_compiler_variables "\n " extra_compiler_variables)
+
set(_cl_content
"cmake_minimum_required(VERSION ${CMAKE_VERSION})
project(Check${lang} ${lang})
file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
\"set(CMAKE_${lang}_COMPILER \\\"\${CMAKE_${lang}_COMPILER}\\\")\\n\"
- \"${extra_compiler_variables}\\n\"
+ ${extra_compiler_variables}
)"
)
@@ -95,6 +109,11 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
else()
set(_D_CMAKE_TOOLCHAIN_FILE "")
endif()
+ if(CMAKE_${lang}_PLATFORM)
+ set(_D_CMAKE_LANG_PLATFORM "-DCMAKE_${lang}_PLATFORM:STRING=${CMAKE_${lang}_PLATFORM}")
+ else()
+ set(_D_CMAKE_LANG_PLATFORM "")
+ endif()
execute_process(
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}
COMMAND ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR}
@@ -103,6 +122,7 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
${_D_CMAKE_GENERATOR_INSTANCE}
${_D_CMAKE_MAKE_PROGRAM}
${_D_CMAKE_TOOLCHAIN_FILE}
+ ${_D_CMAKE_LANG_PLATFORM}
OUTPUT_VARIABLE _cl_output
ERROR_VARIABLE _cl_output
RESULT_VARIABLE _cl_result
@@ -130,6 +150,10 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
mark_as_advanced(CMAKE_${lang}_HOST_COMPILER)
endif()
+ if(CMAKE_${lang}_PLATFORM)
+ set(CMAKE_${lang}_PLATFORM "${CMAKE_${lang}_PLATFORM}" CACHE STRING "${lang} platform")
+ mark_as_advanced(CMAKE_${lang}_PLATFORM)
+ endif()
endif()
endmacro()