diff options
author | Brad King <brad.king@kitware.com> | 2022-03-10 11:57:12 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-03-10 12:10:38 (GMT) |
commit | 7024596a261f6ea8fc3a9735ac09fa92f19f4594 (patch) | |
tree | 86e0423e5ab8b6d5d10335224163a929f02fdd08 | |
parent | 2a79b647fac5fc702082385cb30fedf82a972b5e (diff) | |
download | CMake-7024596a261f6ea8fc3a9735ac09fa92f19f4594.zip CMake-7024596a261f6ea8fc3a9735ac09fa92f19f4594.tar.gz CMake-7024596a261f6ea8fc3a9735ac09fa92f19f4594.tar.bz2 |
Tests: Fix testing CMAKE_CUDA_ARCHITECTURES=OFF with Clang
Clang does not automatically choose an architecture supported
by the SDK. The `OFF` value is meant for users to provide their
own architecture flags, so provide one as part of the test.
-rw-r--r-- | Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake | 13 | ||||
-rw-r--r-- | Tests/RunCMake/CUDA_architectures/architectures-not-set.cmake | 5 |
2 files changed, 18 insertions, 0 deletions
diff --git a/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake b/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake index 3b63d60..6fecae7 100644 --- a/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake @@ -4,5 +4,18 @@ run_cmake(architectures-all) run_cmake(architectures-all-major) run_cmake(architectures-empty) run_cmake(architectures-invalid) + run_cmake(architectures-not-set) +include("${RunCMake_BINARY_DIR}/architectures-not-set-build/info.cmake" OPTIONAL) +message(STATUS " CMAKE_CUDA_COMPILER_ID='${CMAKE_CUDA_COMPILER_ID}'") +message(STATUS " CMAKE_CUDA_COMPILER_VERSION='${CMAKE_CUDA_COMPILER_VERSION}'") +message(STATUS " CMAKE_CUDA_ARCHITECTURES='${CMAKE_CUDA_ARCHITECTURES}'") + +if(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang" AND CMAKE_CUDA_ARCHITECTURES) + list(GET CMAKE_CUDA_ARCHITECTURES 0 arch) + set(CMAKE_CUDA_FLAGS --cuda-gpu-arch=sm_${arch}) + message(STATUS "Adding CMAKE_CUDA_FLAGS='${CMAKE_CUDA_FLAGS}' for CMAKE_CUDA_ARCHITECTURES=OFF with Clang.") + set(RunCMake_TEST_OPTIONS "-DCMAKE_CUDA_FLAGS=${CMAKE_CUDA_FLAGS}") +endif() run_cmake(architectures-off) +unset(RunCMake_TEST_OPTIONS) diff --git a/Tests/RunCMake/CUDA_architectures/architectures-not-set.cmake b/Tests/RunCMake/CUDA_architectures/architectures-not-set.cmake index ce5695a..1be5491 100644 --- a/Tests/RunCMake/CUDA_architectures/architectures-not-set.cmake +++ b/Tests/RunCMake/CUDA_architectures/architectures-not-set.cmake @@ -1,2 +1,7 @@ unset(CMAKE_CUDA_ARCHITECTURES) enable_language(CUDA) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" " +set(CMAKE_CUDA_COMPILER_ID \"${CMAKE_CUDA_COMPILER_ID}\") +set(CMAKE_CUDA_COMPILER_VERSION \"${CMAKE_CUDA_COMPILER_VERSION}\") +set(CMAKE_CUDA_ARCHITECTURES \"${CMAKE_CUDA_ARCHITECTURES}\") +") |