summaryrefslogtreecommitdiff
path: root/aten/cmake
diff options
context:
space:
mode:
authorpeterjc123 <peter_jiachen@163.com>2017-11-15 22:38:36 +0800
committerSoumith Chintala <soumith@gmail.com>2017-11-15 09:38:36 -0500
commit737aba3fc5ed009cd91a48715bf7765b6cb8a1a1 (patch)
tree293999a9780dc42e806062a8353e1367284b96f4 /aten/cmake
parent3bb2308a899e83a9320fdde78e25ae4242251f41 (diff)
downloadpytorch-737aba3fc5ed009cd91a48715bf7765b6cb8a1a1.tar.gz
pytorch-737aba3fc5ed009cd91a48715bf7765b6cb8a1a1.tar.bz2
pytorch-737aba3fc5ed009cd91a48715bf7765b6cb8a1a1.zip
Fix cmake scripts for CUDA and MSVC (#3713)
* Fix wrong CUDA generators and allow for new ones * Fix CUDA detection for other generators * Simplify the changed code * Remove useless flags for MSVC
Diffstat (limited to 'aten/cmake')
-rw-r--r--aten/cmake/FindCUDA/FindCUDA.cmake5
-rw-r--r--aten/cmake/FindCUDA/FindCUDA/select_compute_arch.cmake9
2 files changed, 11 insertions, 3 deletions
diff --git a/aten/cmake/FindCUDA/FindCUDA.cmake b/aten/cmake/FindCUDA/FindCUDA.cmake
index e836a6eaed..3990d67002 100644
--- a/aten/cmake/FindCUDA/FindCUDA.cmake
+++ b/aten/cmake/FindCUDA/FindCUDA.cmake
@@ -487,8 +487,9 @@ option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON)
# Extra user settable flags
set(CUDA_NVCC_FLAGS "" CACHE STRING "Semi-colon delimit multiple arguments.")
-if(CMAKE_GENERATOR MATCHES "Visual Studio")
- set(CUDA_HOST_COMPILER "$(VCInstallDir)bin" CACHE FILEPATH "Host side compiler used by NVCC")
+if(MSVC AND NOT "${CMAKE_C_COMPILER}" MATCHES "/cl.exe")
+ find_program(REAL_MSVC_COMPILER cl.exe)
+ set(CUDA_HOST_COMPILER "${REAL_MSVC_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC")
else()
if(APPLE
AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang"
diff --git a/aten/cmake/FindCUDA/FindCUDA/select_compute_arch.cmake b/aten/cmake/FindCUDA/FindCUDA/select_compute_arch.cmake
index 4b274418aa..5e79cdb144 100644
--- a/aten/cmake/FindCUDA/FindCUDA/select_compute_arch.cmake
+++ b/aten/cmake/FindCUDA/FindCUDA/select_compute_arch.cmake
@@ -62,8 +62,15 @@ function(CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE)
" return 0;\n"
"}\n")
+ if(MSVC AND NOT "${CMAKE_C_COMPILER}" MATCHES "/cl.exe")
+ find_program(REAL_MSVC_COMPILER cl.exe)
+ set(CCBIN "${REAL_MSVC_COMPILER}")
+ else()
+ set(CCBIN "${CMAKE_C_COMPILER}")
+ endif()
+
execute_process(COMMAND "${CUDA_NVCC_EXECUTABLE}" "--run" "${cufile}"
- "-ccbin" ${CMAKE_CXX_COMPILER}
+ "-ccbin" ${CCBIN}
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/CMakeFiles/"
RESULT_VARIABLE nvcc_res OUTPUT_VARIABLE nvcc_out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)