diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2019-11-25 21:03:15 (GMT) |
---|---|---|
committer | Robert Maynard <robert.maynard@kitware.com> | 2019-12-16 16:15:12 (GMT) |
commit | e2a5d8374f94c7893109e11173fc770cec8a4683 (patch) | |
tree | 5093bbc3195f66b6c164b991a3552969c894116c /Tests/CudaOnly | |
parent | 29560bf07b49aee326f555aec53b091e3520294b (diff) | |
download | CMake-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/CudaOnly')
-rw-r--r-- | Tests/CudaOnly/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/CudaOnly/Toolkit/CMakeLists.txt | 54 | ||||
-rw-r--r-- | Tests/CudaOnly/Toolkit/main.cu | 8 |
3 files changed, 63 insertions, 0 deletions
diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index 0dd3309..a0575cd 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -6,6 +6,7 @@ ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag) ADD_TEST_MACRO(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols) ADD_TEST_MACRO(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation) ADD_TEST_MACRO(CudaOnly.Standard98 CudaOnlyStandard98) +ADD_TEST_MACRO(CudaOnly.Toolkit CudaOnlyToolkit) ADD_TEST_MACRO(CudaOnly.WithDefs CudaOnlyWithDefs) add_test(NAME CudaOnly.DontResolveDeviceSymbols COMMAND diff --git a/Tests/CudaOnly/Toolkit/CMakeLists.txt b/Tests/CudaOnly/Toolkit/CMakeLists.txt new file mode 100644 index 0000000..682e56e --- /dev/null +++ b/Tests/CudaOnly/Toolkit/CMakeLists.txt @@ -0,0 +1,54 @@ +cmake_minimum_required(VERSION 3.15) +project(CudaOnlyToolkit CUDA) +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 and variables exist +foreach (cuda_lib cudart cuda_driver cublas cufft cufftw curand cusolver cusparse nvgraph) + if(NOT CUDA_${cuda_lib}_LIBRARY) + message(FATAL_ERROR "expected CUDAToolkit variable CUDA_${cuda_lib}_LIBRARY not found") + endif() + if(NOT TARGET CUDA::${cuda_lib}) + message(FATAL_ERROR "expected CUDAToolkit target CUDA::${cuda_lib} not found") + endif() +endforeach() + +foreach (cuda_lib nppc nppial nppicc nppidei nppif nppig nppim nppist nppitc npps nppicom nppisu) + if(NOT CUDA_${cuda_lib}_LIBRARY) + message(FATAL_ERROR "expected CUDAToolkit variable CUDA_${cuda_lib}_LIBRARY not found") + endif() + if(NOT TARGET CUDA::${cuda_lib}) + message(FATAL_ERROR "expected CUDAToolkit target CUDA::${cuda_lib} not found") + endif() +endforeach() + +foreach (cuda_lib nvrtc nvToolsExt OpenCL culibos) + if(NOT CUDA_${cuda_lib}_LIBRARY) + message(FATAL_ERROR "expected CUDAToolkit variable CUDA_${cuda_lib}_LIBRARY not found") + endif() + + if(NOT TARGET CUDA::${cuda_lib}) + message(FATAL_ERROR "expected CUDAToolkit target CUDA::${cuda_lib} not found") + endif() +endforeach() + +#libraries added as CUDA 10 +if(CUDAToolkit_VERSION_MAJOR VERSION_GREATER 9) + if(NOT CUDA_nvjpeg_LIBRARY) + message(FATAL_ERROR "expected CUDAToolkit variable CUDA_nvjpeg_LIBRARY not found") + endif() + if(NOT TARGET CUDA::nvjpeg) + message(FATAL_ERROR "The CUDA::nvjpeg target was expected but couldn't be found") + endif() +endif() + +add_executable(CudaOnlyToolkit main.cu) +target_link_libraries(CudaOnlyToolkit PRIVATE CUDA::toolkit) diff --git a/Tests/CudaOnly/Toolkit/main.cu b/Tests/CudaOnly/Toolkit/main.cu new file mode 100644 index 0000000..0f3ccdc --- /dev/null +++ b/Tests/CudaOnly/Toolkit/main.cu @@ -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(int argc, char** argv) +{ + return 0; +} |