summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCUDACompiler.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-09-18 17:38:25 (GMT)
committerBrad King <brad.king@kitware.com>2023-09-21 19:34:28 (GMT)
commitb3a1f175677016d4314793f91e255f384c320ec7 (patch)
tree3ab8a9009b6cef87345f175abd4bebfd20e4080e /Modules/CMakeDetermineCUDACompiler.cmake
parent8617c28221cac2bd89402178b25dcd47445a9349 (diff)
downloadCMake-b3a1f175677016d4314793f91e255f384c320ec7.zip
CMake-b3a1f175677016d4314793f91e255f384c320ec7.tar.gz
CMake-b3a1f175677016d4314793f91e255f384c320ec7.tar.bz2
CUDA: Factor out helper to validate CMAKE_CUDA_ARCHITECTURES
Prepare to use it for other languages.
Diffstat (limited to 'Modules/CMakeDetermineCUDACompiler.cmake')
-rw-r--r--Modules/CMakeDetermineCUDACompiler.cmake20
1 files changed, 3 insertions, 17 deletions
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake
index 481a15b..585b2aa 100644
--- a/Modules/CMakeDetermineCUDACompiler.cmake
+++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -111,23 +111,9 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN)
endif()
endif()
- # Rest of the code treats an empty value as equivalent to "use the defaults".
- # Error out early to prevent confusing errors as a result of this.
- # Note that this also catches invalid non-numerical values such as "a".
- if(DEFINED CMAKE_CUDA_ARCHITECTURES)
- if(CMAKE_CUDA_ARCHITECTURES STREQUAL "")
- message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES must be non-empty if set.")
- elseif(CMAKE_CUDA_ARCHITECTURES AND NOT CMAKE_CUDA_ARCHITECTURES MATCHES "^([0-9]+a?(-real|-virtual)?(;[0-9]+a?(-real|-virtual)?|;)*|all|all-major|native)$")
- message(FATAL_ERROR
- "CMAKE_CUDA_ARCHITECTURES:\n"
- " ${CMAKE_CUDA_ARCHITECTURES}\n"
- "is not one of the following:\n"
- " * a semicolon-separated list of integers, each optionally\n"
- " followed by '-real' or '-virtual'\n"
- " * a special value: all, all-major, native\n"
- )
- endif()
- endif()
+ # If the user set CMAKE_CUDA_ARCHITECTURES, validate its value.
+ include(Internal/CMakeCUDAArchitecturesValidate)
+ cmake_cuda_architectures_validate(CUDA)
if(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")
# Clang doesn't automatically select an architecture supported by the SDK.