summaryrefslogtreecommitdiffstats
path: root/Tests/Cuda/Toolkit
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2019-11-25 21:03:15 (GMT)
committerRobert Maynard <robert.maynard@kitware.com>2019-12-16 16:15:12 (GMT)
commite2a5d8374f94c7893109e11173fc770cec8a4683 (patch)
tree5093bbc3195f66b6c164b991a3552969c894116c /Tests/Cuda/Toolkit
parent29560bf07b49aee326f555aec53b091e3520294b (diff)
downloadCMake-e2a5d8374f94c7893109e11173fc770cec8a4683.zip
CMake-e2a5d8374f94c7893109e11173fc770cec8a4683.tar.gz
CMake-e2a5d8374f94c7893109e11173fc770cec8a4683.tar.bz2
FindCUDAToolkit: Improve usage, library set, and tests
Refined the initial design of FindCUDAToolkit and improve it by adding more library support, more toolkit information and tests.
Diffstat (limited to 'Tests/Cuda/Toolkit')
-rw-r--r--Tests/Cuda/Toolkit/CMakeLists.txt45
-rw-r--r--Tests/Cuda/Toolkit/main.cpp8
2 files changed, 53 insertions, 0 deletions
diff --git a/Tests/Cuda/Toolkit/CMakeLists.txt b/Tests/Cuda/Toolkit/CMakeLists.txt
new file mode 100644
index 0000000..45b700b
--- /dev/null
+++ b/Tests/Cuda/Toolkit/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.15)
+project(Toolkit CXX)
+
+#Goal for this example:
+# Validate that we can use CUDAToolkit to find cuda include paths
+find_package(CUDAToolkit REQUIRED)
+
+message(STATUS "CUDAToolkit_VERSION: ${CUDAToolkit_VERSION}")
+message(STATUS "CUDAToolkit_VERSION_MAJOR: ${CUDAToolkit_VERSION_MAJOR}")
+message(STATUS "CUDAToolkit_VERSION_MINOR: ${CUDAToolkit_VERSION_MINOR}")
+message(STATUS "CUDAToolkit_VERSION_PATCH: ${CUDAToolkit_VERSION_PATCH}")
+message(STATUS "CUDAToolkit_BIN_DIR: ${CUDAToolkit_BIN_DIR}")
+message(STATUS "CUDAToolkit_INCLUDE_DIRS: ${CUDAToolkit_INCLUDE_DIRS}")
+message(STATUS "CUDAToolkit_LIBRARY_DIR: ${CUDAToolkit_LIBRARY_DIR}")
+message(STATUS "CUDAToolkit_NVCC_EXECUTABLE ${CUDAToolkit_NVCC_EXECUTABLE}")
+
+# Verify that all the CUDA:: targets exist even when the CUDA language isn't enabled
+
+foreach (cuda_lib cudart cuda_driver cublas cufft cufftw curand cusolver cusparse nvgraph)
+ if(NOT TARGET CUDA::${cuda_lib})
+ message(FATAL_ERROR "The CUDA::${cuda_lib} target was expected but couldn't be found")
+ endif()
+endforeach()
+
+foreach (cuda_lib nppc nppial nppicc nppidei nppif nppig nppim nppist nppitc npps nppicom nppisu)
+ if(NOT TARGET CUDA::${cuda_lib})
+ message(FATAL_ERROR "The CUDA::${cuda_lib} target was expected but couldn't be found")
+ endif()
+endforeach()
+
+foreach (cuda_lib nvrtc nvToolsExt OpenCL culibos)
+ if(NOT TARGET CUDA::${cuda_lib})
+ message(FATAL_ERROR "The CUDA::${cuda_lib} target was expected but couldn't be found")
+ endif()
+endforeach()
+
+#libraries added CUDA 10
+if(CUDAToolkit_VERSION_MAJOR VERSION_GREATER 9)
+ if(NOT TARGET CUDA::nvjpeg)
+ message(FATAL_ERROR "The CUDA::nvjpeg target was expected but couldn't be found")
+ endif()
+endif()
+
+add_executable(Toolkit main.cpp)
+target_link_libraries(Toolkit PRIVATE CUDA::toolkit)
diff --git a/Tests/Cuda/Toolkit/main.cpp b/Tests/Cuda/Toolkit/main.cpp
new file mode 100644
index 0000000..c8d5c6b
--- /dev/null
+++ b/Tests/Cuda/Toolkit/main.cpp
@@ -0,0 +1,8 @@
+// Only thing we care about is that these headers are found
+#include <cuda.h>
+#include <cuda_runtime_api.h>
+
+int main()
+{
+ return 0;
+}