summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeTestCUDACompiler.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-09-15 15:47:28 (GMT)
committerBrad King <brad.king@kitware.com>2023-09-21 19:34:28 (GMT)
commit8617c28221cac2bd89402178b25dcd47445a9349 (patch)
tree4570dd05f43aedb4d2f14c13a9c1d5e188654ad9 /Modules/CMakeTestCUDACompiler.cmake
parent0db0fe7958346ace0f5f01496e071c365faf3eb9 (diff)
downloadCMake-8617c28221cac2bd89402178b25dcd47445a9349.zip
CMake-8617c28221cac2bd89402178b25dcd47445a9349.tar.gz
CMake-8617c28221cac2bd89402178b25dcd47445a9349.tar.bz2
CUDA: Factor out helper for detecting native CUDA architectures
Prepare to use it for other languages.
Diffstat (limited to 'Modules/CMakeTestCUDACompiler.cmake')
-rw-r--r--Modules/CMakeTestCUDACompiler.cmake49
1 files changed, 4 insertions, 45 deletions
diff --git a/Modules/CMakeTestCUDACompiler.cmake b/Modules/CMakeTestCUDACompiler.cmake
index 79ee20f..3057fe9 100644
--- a/Modules/CMakeTestCUDACompiler.cmake
+++ b/Modules/CMakeTestCUDACompiler.cmake
@@ -22,51 +22,10 @@ if(CMAKE_CUDA_ABI_COMPILED)
set(CMAKE_CUDA_COMPILER_WORKS TRUE)
message(STATUS "Check for working CUDA compiler: ${CMAKE_CUDA_COMPILER} - skipped")
- # Run the test binary to detect the native architectures.
- execute_process(COMMAND "${CMAKE_PLATFORM_INFO_DIR}/CMakeDetermineCompilerABI_CUDA.bin"
- RESULT_VARIABLE _CUDA_ARCHS_RESULT
- OUTPUT_VARIABLE _CUDA_ARCHS_OUTPUT
- ERROR_VARIABLE _CUDA_ARCHS_OUTPUT
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
- if(_CUDA_ARCHS_RESULT EQUAL 0)
- if("$ENV{CMAKE_CUDA_ARCHITECTURES_NATIVE_CLAMP}")
- # Undocumented hook used by CMake's CI.
- # Clamp native architecture to version range supported by this CUDA.
- list(GET CMAKE_CUDA_ARCHITECTURES_ALL 0 _CUDA_ARCH_MIN)
- list(GET CMAKE_CUDA_ARCHITECTURES_ALL -1 _CUDA_ARCH_MAX)
- set(CMAKE_CUDA_ARCHITECTURES_NATIVE "")
- foreach(_CUDA_ARCH IN LISTS _CUDA_ARCHS_OUTPUT)
- if(_CUDA_ARCH LESS _CUDA_ARCH_MIN)
- set(_CUDA_ARCH "${_CUDA_ARCH_MIN}")
- endif()
- if(_CUDA_ARCH GREATER _CUDA_ARCH_MAX)
- set(_CUDA_ARCH "${_CUDA_ARCH_MAX}")
- endif()
- list(APPEND CMAKE_CUDA_ARCHITECTURES_NATIVE ${_CUDA_ARCH})
- endforeach()
- unset(_CUDA_ARCH)
- unset(_CUDA_ARCH_MIN)
- unset(_CUDA_ARCH_MAX)
- else()
- set(CMAKE_CUDA_ARCHITECTURES_NATIVE "${_CUDA_ARCHS_OUTPUT}")
- endif()
- list(REMOVE_DUPLICATES CMAKE_CUDA_ARCHITECTURES_NATIVE)
- list(TRANSFORM CMAKE_CUDA_ARCHITECTURES_NATIVE APPEND "-real")
- else()
- if(NOT _CUDA_ARCHS_RESULT MATCHES "[0-9]+")
- set(_CUDA_ARCHS_STATUS " (${_CUDA_ARCHS_RESULT})")
- else()
- set(_CUDA_ARCHS_STATUS "")
- endif()
- string(REPLACE "\n" "\n " _CUDA_ARCHS_OUTPUT " ${_CUDA_ARCHS_OUTPUT}")
- message(CONFIGURE_LOG
- "Detecting the CUDA native architecture(s) failed with "
- "the following output:\n${_CUDA_ARCHS_OUTPUT}\n\n")
- endif()
- unset(_CUDA_ARCHS_EXE)
- unset(_CUDA_ARCHS_RESULT)
- unset(_CUDA_ARCHS_OUTPUT)
+ include(Internal/CMakeCUDAArchitecturesNative)
+ # Run the test binary to get:
+ # - CMAKE_CUDA_ARCHITECTURES_NATIVE
+ cmake_cuda_architectures_native(CUDA)
endif()
# This file is used by EnableLanguage in cmGlobalGenerator to