diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2016-11-01 20:11:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-11-14 21:40:50 (GMT) |
commit | 7b9131da64b4b569e10ec145fab0c8e22fa69761 (patch) | |
tree | bf3cf32fa6515c1d197e7950262094290b797e6e /Tests/CudaOnly/EnableStandard | |
parent | 9cf5b98d54497b425fe341e4ad5bc188d9fa5445 (diff) | |
download | CMake-7b9131da64b4b569e10ec145fab0c8e22fa69761.zip CMake-7b9131da64b4b569e10ec145fab0c8e22fa69761.tar.gz CMake-7b9131da64b4b569e10ec145fab0c8e22fa69761.tar.bz2 |
CUDA: Add tests to verify CUDA compiler works properly.
Diffstat (limited to 'Tests/CudaOnly/EnableStandard')
-rw-r--r-- | Tests/CudaOnly/EnableStandard/CMakeLists.txt | 15 | ||||
-rw-r--r-- | Tests/CudaOnly/EnableStandard/main.cu | 17 | ||||
-rw-r--r-- | Tests/CudaOnly/EnableStandard/shared.cu | 9 | ||||
-rw-r--r-- | Tests/CudaOnly/EnableStandard/static.cu | 9 |
4 files changed, 50 insertions, 0 deletions
diff --git a/Tests/CudaOnly/EnableStandard/CMakeLists.txt b/Tests/CudaOnly/EnableStandard/CMakeLists.txt new file mode 100644 index 0000000..53b9132 --- /dev/null +++ b/Tests/CudaOnly/EnableStandard/CMakeLists.txt @@ -0,0 +1,15 @@ + +cmake_minimum_required(VERSION 3.7) +project (CudaOnlyEnableStandard CUDA) + +#Goal for this example: +#build cuda sources that require C++11 to be enabled. + +add_library(CUDAStatic11 STATIC static.cu) +add_library(CUDADynamic11 SHARED shared.cu) + +add_executable(CudaOnlyEnableStandard main.cu) +target_link_libraries(CudaOnlyEnableStandard PRIVATE CUDAStatic11 CUDADynamic11) + +set_target_properties(CUDAStatic11 CUDADynamic11 PROPERTIES CUDA_STANDARD 11) +set_target_properties(CUDAStatic11 CUDADynamic11 PROPERTIES CUDA_STANDARD_REQUIRED TRUE) diff --git a/Tests/CudaOnly/EnableStandard/main.cu b/Tests/CudaOnly/EnableStandard/main.cu new file mode 100644 index 0000000..83e9dfd --- /dev/null +++ b/Tests/CudaOnly/EnableStandard/main.cu @@ -0,0 +1,17 @@ + +#include <iostream> + +int static_cuda11_func(int); +int shared_cuda11_func(int); + +void test_functions() +{ + static_cuda11_func( int(42) ); + shared_cuda11_func( int(42) ); +} + +int main(int argc, char **argv) +{ + test_functions(); + return 0; +} diff --git a/Tests/CudaOnly/EnableStandard/shared.cu b/Tests/CudaOnly/EnableStandard/shared.cu new file mode 100644 index 0000000..28555b3 --- /dev/null +++ b/Tests/CudaOnly/EnableStandard/shared.cu @@ -0,0 +1,9 @@ + +#include <type_traits> + +using tt = std::true_type; +using ft = std::false_type; +int __host__ shared_cuda11_func(int x) +{ + return x * x + std::integral_constant<int, 17>::value; +} diff --git a/Tests/CudaOnly/EnableStandard/static.cu b/Tests/CudaOnly/EnableStandard/static.cu new file mode 100644 index 0000000..73e43a8 --- /dev/null +++ b/Tests/CudaOnly/EnableStandard/static.cu @@ -0,0 +1,9 @@ + +#include <type_traits> + +using tt = std::true_type; +using ft = std::false_type; +int __host__ static_cuda11_func(int x) +{ + return x * x + std::integral_constant<int, 17>::value; +} |