CUDA_SELECT_NVCC_ARCH_FLAGS Auto does not work for MSVC
execute_process(COMMAND "{CUDA_NVCC_EXECUTABLE}" "--run" "
{cufile}" ...
does not work because nvcc cannot find cl.exe.
I suggest renaming detect_cuda_archs.cu --> detect_cuda_compute_capabilities.cpp, adding
#include <cuda_runtime.h>
as first line in cufile, and replacing execute_process(...) with the following:
try_run( nvcc_res compile_result ${PROJECT_BINARY_DIR} ${cufile}
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CUDA_INCLUDE_DIRS}"
LINK_LIBRARIES ${CUDA_LIBRARIES}
RUN_OUTPUT_VARIABLE nvcc_out
)
Renaming cufile --> file, nvcc_res --> run_result, and nvcc_out --> compute_capabilities makes it consistent.