From 23119366e9d4e56e13c1fdec9dbff5e8f8c55ee5 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Wed, 28 Mar 2018 11:33:56 -0400 Subject: FindCUDA: Make nvcc configurable via CUDA_NVCC_EXECUTABLE env var This is useful if, for example, you want ccache to be used for nvcc. With the current behavior, cmake always picks up /usr/local/cuda/bin/nvcc, even if there is a ccache nvcc stub in the PATH. Allowing for CUDA_NVCC_EXECUTABLE lets us work around the problem. Signed-off-by: Edward Z. Yang --- Modules/FindCUDA.cmake | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 119fc13..6f6f349 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -733,16 +733,20 @@ endif() # CUDA_NVCC_EXECUTABLE -cuda_find_host_program(CUDA_NVCC_EXECUTABLE - NAMES nvcc - PATHS "${CUDA_TOOLKIT_ROOT_DIR}" - ENV CUDA_PATH - ENV CUDA_BIN_PATH - PATH_SUFFIXES bin bin64 - NO_DEFAULT_PATH - ) -# Search default search paths, after we search our own set of paths. -cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc) +if(DEFINED ENV{CUDA_NVCC_EXECUTABLE}) + set(CUDA_NVCC_EXECUTABLE "$ENV{CUDA_NVCC_EXECUTABLE}" CACHE FILEPATH "The CUDA compiler") +else() + cuda_find_host_program(CUDA_NVCC_EXECUTABLE + NAMES nvcc + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 + NO_DEFAULT_PATH + ) + # Search default search paths, after we search our own set of paths. + cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc) +endif() mark_as_advanced(CUDA_NVCC_EXECUTABLE) if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_VERSION) -- cgit v0.12