summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorpeterjc123 <peter_jiachen@163.com>2018-09-15 09:14:38 (GMT)
committerBrad King <brad.king@kitware.com>2018-09-18 15:41:47 (GMT)
commit8085799ce3a311e3f0f3c2f2119ae0dcb8b2e0a3 (patch)
tree4068c04c502c01b3aaff0d226e49446ec414189f /Modules
parent18eb4c637a6fb35bf8207e5f39d3e701fdcf973b (diff)
downloadCMake-8085799ce3a311e3f0f3c2f2119ae0dcb8b2e0a3.zip
CMake-8085799ce3a311e3f0f3c2f2119ae0dcb8b2e0a3.tar.gz
CMake-8085799ce3a311e3f0f3c2f2119ae0dcb8b2e0a3.tar.bz2
FindCUDA: Add option to set CUDA_HOST_COMPILER via environment
Re-use the `CUDAHOSTCXX` environment variable from the first-class CUDA language support to specify the host compiler for FindCUDA.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindCUDA.cmake6
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index 1650e55..686e2e7 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -105,6 +105,8 @@
# 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 within VS.
+# If the CUDAHOSTCXX environment variable is set it will
+# be used as the default.
#
# CUDA_NVCC_FLAGS
# CUDA_NVCC_FLAGS_<CONFIG>
@@ -527,7 +529,9 @@ option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON)
# Extra user settable flags
cmake_initialize_per_config_variable(CUDA_NVCC_FLAGS "Semi-colon delimit multiple arguments.")
-if(CMAKE_GENERATOR MATCHES "Visual Studio")
+if(DEFINED ENV{CUDAHOSTCXX})
+ set(CUDA_HOST_COMPILER "$ENV{CUDAHOSTCXX}" CACHE FILEPATH "Host side compiler used by NVCC")
+elseif(CMAKE_GENERATOR MATCHES "Visual Studio")
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")