diff options
author | Raul Tambre <raul@tambre.ee> | 2021-12-27 18:40:29 (GMT) |
---|---|---|
committer | Raul Tambre <raul@tambre.ee> | 2022-01-27 20:11:13 (GMT) |
commit | 7a0d0983521cbd16030add2afbb0f7d9e75cce6f (patch) | |
tree | 0ec31eaa38525b49c7003c9b3401acf32eecfa5f /Modules | |
parent | d19273bc7b361a54041706c02857993e244d3b50 (diff) | |
download | CMake-7a0d0983521cbd16030add2afbb0f7d9e75cce6f.zip CMake-7a0d0983521cbd16030add2afbb0f7d9e75cce6f.tar.gz CMake-7a0d0983521cbd16030add2afbb0f7d9e75cce6f.tar.bz2 |
CUDA: Error on empty/invalid CMAKE_CUDA_ARCHITECTURES set by user
If empty we otherwise treat it the same as unset in most places, but still end
up failing eventually with a confusing "Failed to find a working CUDA
architecture".
This also detects some other basic invalid ones (e.g. "al").
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeDetermineCUDACompiler.cmake | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 49e4c75..73b1017 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -257,7 +257,7 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) endif() # Append user-specified architectures. - if(CMAKE_CUDA_ARCHITECTURES) + if(DEFINED CMAKE_CUDA_ARCHITECTURES) if("x${CMAKE_CUDA_ARCHITECTURES}" STREQUAL "xall") string(APPEND nvcc_test_flags " -arch=all") set(architectures_mode all) @@ -279,6 +279,13 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) set(CMAKE_CUDA_COMPILER_ID_REQUIRE_SUCCESS ON) 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(architectures_mode STREQUAL "explicit" AND "${tested_architectures}" STREQUAL "") + message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES must be valid if set.") + endif() + if(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang") if(NOT CMAKE_CUDA_ARCHITECTURES) # Clang doesn't automatically select an architecture supported by the SDK. |