diff options
author | Raul Tambre <raul@tambre.ee> | 2020-06-12 16:59:32 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-06-15 13:13:32 (GMT) |
commit | 877a92e968bfa24d86f4b9685b5c27d4c9e6c1be (patch) | |
tree | 3c410caeece84452eff2f1ef27eb01b5b1b54f1f /Tests | |
parent | 594fda9c234915669dbfe61bec7c59250e747b4a (diff) | |
download | CMake-877a92e968bfa24d86f4b9685b5c27d4c9e6c1be.zip CMake-877a92e968bfa24d86f4b9685b5c27d4c9e6c1be.tar.gz CMake-877a92e968bfa24d86f4b9685b5c27d4c9e6c1be.tar.bz2 |
CUDA: Add support for disabling CUDA_ARCHITECTURES
The ability to disable adding architectures completely for packaging purposes
and cases requiring passing the architectures flags explicitly has been
requested.
Support a false value for CUDA_ARCHITECTURES and CMAKE_CUDA_ARCHITECTURES
for this purpose.
Implements #20821.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CudaOnly/Architecture/CMakeLists.txt | 14 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0104/CMP0104-OFF.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0104/RunCMakeTest.cmake | 1 |
3 files changed, 16 insertions, 2 deletions
diff --git a/Tests/CudaOnly/Architecture/CMakeLists.txt b/Tests/CudaOnly/Architecture/CMakeLists.txt index 7270b56..03e972f 100644 --- a/Tests/CudaOnly/Architecture/CMakeLists.txt +++ b/Tests/CudaOnly/Architecture/CMakeLists.txt @@ -1,5 +1,15 @@ -cmake_minimum_required(VERSION 3.17) +cmake_minimum_required(VERSION 3.18) project(Architecture CUDA) -set(CMAKE_CUDA_ARCHITECTURES 52) add_executable(Architecture main.cu) +set_property(TARGET Architecture PROPERTY CUDA_ARCHITECTURES 52) + +# Make sure CMake doesn't pass architectures if CUDA_ARCHITECTURES is OFF. +if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -arch=sm_52") +elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang") + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --cuda-gpu-arch=sm_52") +endif() + +add_executable(ArchitectureOff main.cu) +set_property(TARGET ArchitectureOff PROPERTY CUDA_ARCHITECTURES OFF) diff --git a/Tests/RunCMake/CMP0104/CMP0104-OFF.cmake b/Tests/RunCMake/CMP0104/CMP0104-OFF.cmake new file mode 100644 index 0000000..f3b6682 --- /dev/null +++ b/Tests/RunCMake/CMP0104/CMP0104-OFF.cmake @@ -0,0 +1,3 @@ +include(CMP0104-Common.cmake) + +set_property(TARGET cuda PROPERTY CUDA_ARCHITECTURES OFF) diff --git a/Tests/RunCMake/CMP0104/RunCMakeTest.cmake b/Tests/RunCMake/CMP0104/RunCMakeTest.cmake index bc8e1b1..b26f72a 100644 --- a/Tests/RunCMake/CMP0104/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0104/RunCMakeTest.cmake @@ -2,4 +2,5 @@ include(RunCMake) run_cmake(CMP0104-OLD) run_cmake(CMP0104-NEW) +run_cmake(CMP0104-OFF) run_cmake(CMP0104-WARN) |