diff options
author | Brad King <brad.king@kitware.com> | 2018-01-09 14:26:16 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-01-09 14:26:20 (GMT) |
commit | bc88329e5ba7b1a14538f23f4fa223ac8d6d5895 (patch) | |
tree | c0f82a7f529ac1d4dbdc5fdc14f1c7b401095fec | |
parent | 89d12746306571a323549ad0f8d11284999053d5 (diff) | |
parent | fab1b432eb1207513bee57039ecb21d95f880f89 (diff) | |
download | CMake-bc88329e5ba7b1a14538f23f4fa223ac8d6d5895.zip CMake-bc88329e5ba7b1a14538f23f4fa223ac8d6d5895.tar.gz CMake-bc88329e5ba7b1a14538f23f4fa223ac8d6d5895.tar.bz2 |
Merge topic 'msvc2017-findcuda'
fab1b432 FindCUDA: Update to properly find MSVC 2017 compiler tools
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard <robert.maynard@kitware.com>
Merge-request: !1631
-rw-r--r-- | Modules/FindCUDA.cmake | 23 | ||||
-rw-r--r-- | Modules/FindCUDA/run_nvcc.cmake | 2 |
2 files changed, 16 insertions, 9 deletions
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 4f4453b..2199edb 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -98,12 +98,13 @@ # CUDA_HOST_COMPILATION_CPP (Default ON) # -- Set to OFF for C compilation of host code. # -# CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER, $(VCInstallDir)/bin for VS) +# CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER) # -- Set the host compiler to be used by nvcc. Ignored if -ccbin or # --compiler-bindir is already present in the CUDA_NVCC_FLAGS or -# CUDA_NVCC_FLAGS_<CONFIG> variables. For Visual Studio targets -# $(VCInstallDir)/bin is a special value that expands out to the path when -# the command is run from within VS. +# CUDA_NVCC_FLAGS_<CONFIG> variables. For Visual Studio targets, +# the host compiler is constructed with one or more visual studio macros +# such as $(VCInstallDir), that expands out to the path when +# the command is run from withing VS. # # CUDA_NVCC_FLAGS # CUDA_NVCC_FLAGS_<CONFIG> @@ -527,7 +528,13 @@ option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON) 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") + set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)") + if(MSVC_VERSION LESS 1910) + set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)bin") + endif() + + set(CUDA_HOST_COMPILER "${_CUDA_MSVC_HOST_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC") + else() if(APPLE AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang" @@ -1318,11 +1325,11 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) endif() # This needs to be passed in at this stage, because VS needs to fill out the - # value of VCInstallDir from within VS. Note that CCBIN is only used if + # various macros from within VS. Note that CCBIN is only used if # -ccbin or --compiler-bindir isn't used and CUDA_HOST_COMPILER matches - # $(VCInstallDir)/bin. + # _CUDA_MSVC_HOST_COMPILER if(CMAKE_GENERATOR MATCHES "Visual Studio") - set(ccbin_flags -D "\"CCBIN:PATH=$(VCInstallDir)bin\"" ) + set(ccbin_flags -D "\"CCBIN:PATH=${_CUDA_MSVC_HOST_COMPILER}\"" ) else() set(ccbin_flags) endif() diff --git a/Modules/FindCUDA/run_nvcc.cmake b/Modules/FindCUDA/run_nvcc.cmake index a20ef8f..6fc2439 100644 --- a/Modules/FindCUDA/run_nvcc.cmake +++ b/Modules/FindCUDA/run_nvcc.cmake @@ -125,7 +125,7 @@ list(APPEND CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS_${build_configuration}}) list( FIND CUDA_NVCC_FLAGS "-ccbin" ccbin_found0 ) list( FIND CUDA_NVCC_FLAGS "--compiler-bindir" ccbin_found1 ) if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER ) - if (CUDA_HOST_COMPILER STREQUAL "$(VCInstallDir)bin" AND DEFINED CCBIN) + if (CUDA_HOST_COMPILER STREQUAL "@_CUDA_MSVC_HOST_COMPILER@" AND DEFINED CCBIN) set(CCBIN -ccbin "${CCBIN}") else() set(CCBIN -ccbin "${CUDA_HOST_COMPILER}") |