Commit 8d75d8dc authored by Brad King's avatar Brad King

Tests: Add case for CUDA with C but not C++

An executable using CUDA and C should link as CUDA.
parent c4a61350
......@@ -4,3 +4,4 @@ ADD_TEST_MACRO(Cuda.ConsumeCompileFeatures CudaConsumeCompileFeatures)
ADD_TEST_MACRO(Cuda.ObjectLibrary CudaObjectLibrary)
ADD_TEST_MACRO(Cuda.ToolkitInclude CudaToolkitInclude)
ADD_TEST_MACRO(Cuda.ProperLinkFlags ProperLinkFlags)
ADD_TEST_MACRO(Cuda.WithC CudaWithC)
cmake_minimum_required(VERSION 3.7)
project(CudaComplex CUDA C)
set(CMAKE_CUDA_FLAGS "-gencode arch=compute_30,code=compute_30")
add_executable(CudaWithC main.c
# We need to add the default path to the driver (libcuda.dylib) as an rpath, so that
# the static cuda runtime can find it at runtime.
target_link_libraries(CudaWithC PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
#include <cuda.h>
#include <iostream>
extern "C" int use_cuda(void)
int nDevices = 0;
cudaError_t err = cudaGetDeviceCount(&nDevices);
if (err != cudaSuccess) {
std::cerr << "Failed to retrieve the number of CUDA enabled devices"
<< std::endl;
return 1;
std::cout << "Found " << nDevices << " CUDA enabled devices" << std::endl;
return 0;
extern int use_cuda(void);
int main()
return use_cuda();
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment