diff options
author | Brad King <brad.king@kitware.com> | 2017-01-26 15:40:44 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2017-01-26 15:40:44 (GMT) |
commit | 90ee3bd3b0b22c62cbb96334ba6620b89ea3d6be (patch) | |
tree | f6514a53a759ca814d1768f4ea5f98ed69c3dfe2 | |
parent | 4ab35eb661f92686cc3ed3a1b52f7c2ef49bf8a1 (diff) | |
parent | c1f3086de70793ee5552986347291d814b796232 (diff) | |
download | CMake-90ee3bd3b0b22c62cbb96334ba6620b89ea3d6be.zip CMake-90ee3bd3b0b22c62cbb96334ba6620b89ea3d6be.tar.gz CMake-90ee3bd3b0b22c62cbb96334ba6620b89ea3d6be.tar.bz2 |
Merge topic 'FindCUDA-select-flags-auto-msvc'
c1f3086d FindCUDA: Enable CUDA_SELECT_NVCC_ARCH_FLAGS Auto for MSVC
-rw-r--r-- | Modules/FindCUDA/select_compute_arch.cmake | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/Modules/FindCUDA/select_compute_arch.cmake b/Modules/FindCUDA/select_compute_arch.cmake index 5ce71a9..19fc14f 100644 --- a/Modules/FindCUDA/select_compute_arch.cmake +++ b/Modules/FindCUDA/select_compute_arch.cmake @@ -44,9 +44,10 @@ endif () # function(CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE) if(NOT CUDA_GPU_DETECT_OUTPUT) - set(cufile ${PROJECT_BINARY_DIR}/detect_cuda_archs.cu) + set(file ${PROJECT_BINARY_DIR}/detect_cuda_compute_capabilities.cpp) - file(WRITE ${cufile} "" + file(WRITE ${file} "" + "#include <cuda_runtime.h>\n" "#include <cstdio>\n" "int main()\n" "{\n" @@ -62,14 +63,15 @@ function(CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE) " return 0;\n" "}\n") - execute_process(COMMAND "${CUDA_NVCC_EXECUTABLE}" "--run" "${cufile}" - WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/CMakeFiles/" - RESULT_VARIABLE nvcc_res OUTPUT_VARIABLE nvcc_out - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + try_run(run_result compile_result ${PROJECT_BINARY_DIR} ${file} + CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CUDA_INCLUDE_DIRS}" + LINK_LIBRARIES ${CUDA_LIBRARIES} + RUN_OUTPUT_VARIABLE compute_capabilities) - if(nvcc_res EQUAL 0) - string(REPLACE "2.1" "2.1(2.0)" nvcc_out "${nvcc_out}") - set(CUDA_GPU_DETECT_OUTPUT ${nvcc_out} CACHE INTERNAL "Returned GPU architetures from detect_gpus tool" FORCE) + if(run_result EQUAL 0) + string(REPLACE "2.1" "2.1(2.0)" compute_capabilities "${compute_capabilities}") + set(CUDA_GPU_DETECT_OUTPUT ${compute_capabilities} + CACHE INTERNAL "Returned GPU architetures from detect_gpus tool" FORCE) endif() endif() |