summaryrefslogtreecommitdiffstats
path: root/Tests/CudaOnly/ToolkitBeforeLang/CMakeLists.txt
blob: 8dff6cc539f6187e297040159191ab5babb7af8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
cmake_minimum_required(VERSION 3.15)
project(CudaOnlyToolkitBeforeLang CXX)

# Validate that CUDAToolkit gets the correct version
# when called before CUDA the language is enabled
find_package(CUDAToolkit REQUIRED)
enable_language(CUDA)

if(NOT DEFINED CUDAToolkit_VERSION)
  message(FATAL_ERROR "expected CUDAToolkit variable CUDAToolkit_VERSION not found")
endif()

set(cuda_libs cudart cuda_driver)

# Verify that all the CUDA:: targets and variables exist
foreach (cuda_lib IN LISTS cuda_libs)
  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()

add_executable(CudaOnlyToolkitBeforeLang main.cu)
target_link_libraries(CudaOnlyToolkitBeforeLang PRIVATE CUDA::toolkit)