summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCUDACompiler.cmake
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2016-11-08 16:51:14 (GMT)
committerBrad King <brad.king@kitware.com>2016-11-14 21:40:49 (GMT)
commit9cf5b98d54497b425fe341e4ad5bc188d9fa5445 (patch)
tree764f56d812906c81d9283fc3cc095287bf1004ce /Modules/CMakeDetermineCUDACompiler.cmake
parenta5e806b3f51d91814d8a39a4bb84363d530874bb (diff)
downloadCMake-9cf5b98d54497b425fe341e4ad5bc188d9fa5445.zip
CMake-9cf5b98d54497b425fe341e4ad5bc188d9fa5445.tar.gz
CMake-9cf5b98d54497b425fe341e4ad5bc188d9fa5445.tar.bz2
CUDA: Prefer environment variables CUDACXX and CUDAHOSTCXX.
Diffstat (limited to 'Modules/CMakeDetermineCUDACompiler.cmake')
-rw-r--r--Modules/CMakeDetermineCUDACompiler.cmake19
1 files changed, 18 insertions, 1 deletions
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake
index 9ad4fc6..419f3a5 100644
--- a/Modules/CMakeDetermineCUDACompiler.cmake
+++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -12,6 +12,17 @@ endif()
if(NOT CMAKE_CUDA_COMPILER)
set(CMAKE_CUDA_COMPILER_INIT NOTFOUND)
+ # prefer the environment variable CUDACXX
+ if(NOT $ENV{CUDACXX} STREQUAL "")
+ get_filename_component(CMAKE_CUDA_COMPILER_INIT $ENV{CUDACXX} PROGRAM PROGRAM_ARGS CMAKE_CUDA_FLAGS_ENV_INIT)
+ if(CMAKE_CUDA_FLAGS_ENV_INIT)
+ set(CMAKE_CUDA_COMPILER_ARG1 "${CMAKE_CUDA_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler")
+ endif()
+ if(NOT EXISTS ${CMAKE_CUDA_COMPILER_INIT})
+ message(FATAL_ERROR "Could not find compiler set in environment variable CUDACXX:\n$ENV{CUDACXX}.\n${CMAKE_CUDA_COMPILER_INIT}")
+ endif()
+ endif()
+
# finally list compilers to try
if(NOT CMAKE_CUDA_COMPILER_INIT)
set(CMAKE_CUDA_COMPILER_LIST nvcc)
@@ -25,8 +36,13 @@ endif()
mark_as_advanced(CMAKE_CUDA_COMPILER)
#Allow the user to specify a host compiler
-#todo: need to specify this to compiler test passes
set(CMAKE_CUDA_HOST_COMPILER "" CACHE FILEPATH "Host compiler to be used by nvcc")
+if(NOT $ENV{CUDAHOSTCXX} STREQUAL "")
+ get_filename_component(CMAKE_CUDA_HOST_COMPILER $ENV{CUDAHOSTCXX} PROGRAM)
+ if(NOT EXISTS ${CMAKE_CUDA_HOST_COMPILER})
+ message(FATAL_ERROR "Could not find compiler set in environment variable CUDAHOSTCXX:\n$ENV{CUDAHOSTCXX}.\n${CMAKE_CUDA_HOST_COMPILER}")
+ endif()
+endif()
# Build a small source file to identify the compiler.
if(NOT CMAKE_CUDA_COMPILER_ID_RUN)
@@ -96,3 +112,4 @@ configure_file(${CMAKE_ROOT}/Modules/CMakeCUDACompiler.cmake.in
)
set(CMAKE_CUDA_COMPILER_ENV_VAR "CUDACXX")
+set(CMAKE_CUDA_HOST_COMPILER_ENV_VAR "CUDAHOSTCXX")