diff options
author | Raul Tambre <raul@tambre.ee> | 2020-03-27 19:32:38 (GMT) |
---|---|---|
committer | Raul Tambre <raul@tambre.ee> | 2020-04-15 14:55:41 (GMT) |
commit | 21131ca60cd37cdd306c10781df254e261f27c8a (patch) | |
tree | aa8613797735426f4800a33103fa1419dbac96d4 /Tests | |
parent | f0931b07905a960c7dfbcc90e772219150c24951 (diff) | |
download | CMake-21131ca60cd37cdd306c10781df254e261f27c8a.zip CMake-21131ca60cd37cdd306c10781df254e261f27c8a.tar.gz CMake-21131ca60cd37cdd306c10781df254e261f27c8a.tar.bz2 |
CUDA: Add CudaOnly.CompileFlags test
Covers passing compile flags explicitly for both NVCC and Clang.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CudaOnly/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/CudaOnly/CompileFlags/CMakeLists.txt | 16 | ||||
-rw-r--r-- | Tests/CudaOnly/CompileFlags/main.cu | 16 |
3 files changed, 33 insertions, 0 deletions
diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index 0b2628c..d74e810 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -1,6 +1,7 @@ ADD_TEST_MACRO(CudaOnly.Architecture Architecture) ADD_TEST_MACRO(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine) +ADD_TEST_MACRO(CudaOnly.CompileFlags CudaOnlyCompileFlags) ADD_TEST_MACRO(CudaOnly.EnableStandard CudaOnlyEnableStandard) ADD_TEST_MACRO(CudaOnly.ExportPTX CudaOnlyExportPTX) ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag) diff --git a/Tests/CudaOnly/CompileFlags/CMakeLists.txt b/Tests/CudaOnly/CompileFlags/CMakeLists.txt new file mode 100644 index 0000000..cbce7d6 --- /dev/null +++ b/Tests/CudaOnly/CompileFlags/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.17) +cmake_policy(SET CMP0104 OLD) +project(CompileFlags CUDA) + +# Clear defaults. +set(CMAKE_CUDA_ARCHITECTURES) + +add_executable(CudaOnlyCompileFlags main.cu) + +# Try passing CUDA architecture flags explicitly. +if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") + target_compile_options(CudaOnlyCompileFlags PRIVATE + -gencode arch=compute_50,code=compute_50 + --compiler-options=-DHOST_DEFINE + ) +endif() diff --git a/Tests/CudaOnly/CompileFlags/main.cu b/Tests/CudaOnly/CompileFlags/main.cu new file mode 100644 index 0000000..573d230 --- /dev/null +++ b/Tests/CudaOnly/CompileFlags/main.cu @@ -0,0 +1,16 @@ +#ifdef __CUDA_ARCH__ +# if __CUDA_ARCH__ != 500 +# error "Passed architecture 50, but got something else." +# endif +#endif + +// Check HOST_DEFINE only for nvcc +#ifndef __CUDA__ +# ifndef HOST_DEFINE +# error "HOST_DEFINE not defined!" +# endif +#endif + +int main() +{ +} |