diff --git a/cmake/cuda.cmake b/cmake/cuda.cmake index 514937f760d4178287dcd6619c2b5ea00046f677..170a8667e0b7c3cd752de5cf637a8b4a5763545d 100644 --- a/cmake/cuda.cmake +++ b/cmake/cuda.cmake @@ -26,7 +26,9 @@ function(detect_installed_gpus out_variable) set(cufile ${PROJECT_BINARY_DIR}/detect_cuda_archs.cu) file(WRITE ${cufile} "" - "#include \n" + "#include \"stdio.h\"\n" + "#include \"cuda.h\"\n" + "#include \"cuda_runtime.h\"\n" "int main() {\n" " int count = 0;\n" " if (cudaSuccess != cudaGetDeviceCount(&count)) return -1;\n" @@ -34,12 +36,12 @@ function(detect_installed_gpus out_variable) " for (int device = 0; device < count; ++device) {\n" " cudaDeviceProp prop;\n" " if (cudaSuccess == cudaGetDeviceProperties(&prop, device))\n" - " std::printf(\"%d.%d \", prop.major, prop.minor);\n" + " printf(\"%d.%d \", prop.major, prop.minor);\n" " }\n" " return 0;\n" "}\n") - execute_process(COMMAND "${CUDA_NVCC_EXECUTABLE}" "-ccbin=${CUDA_HOST_COMPILER}" + execute_process(COMMAND "${CUDA_NVCC_EXECUTABLE}" "--run" "${cufile}" WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/CMakeFiles/" RESULT_VARIABLE nvcc_res OUTPUT_VARIABLE nvcc_out