CUDAToolkit ignores CUDAToolkit_ROOT if another nvcc is in PATH
Here is a trace output from the configuration of my project
cmake . -DCUDAToolkit_ROOT=/some/dir
cmake-3.18.2-xm7dwpxesxzgm3ovhglyg4zqerh2lw6s/cmake-3.18/Modules/FindCUDAToolkit.cmake(511): find_program(CUDAToolkit_NVCC_EXECUTABLE NAMES nvcc nvcc.exe PATHS ENV CUDA_PATH PATH_SUFFIXES bin )
cmake-3.18.2-xm7dwpxesxzgm3ovhglyg4zqerh2lw6s/share/cmake-3.18/Modules/FindCUDAToolkit.cmake(518): if(NOT CUDAToolkit_NVCC_EXECUTABLE AND ( DEFINED CUDAToolkit_ROOT OR DEFINED ENV{CUDAToolkit_ROOT} ) )
The evaluation order of the expressions results in find_program picking nvcc
from PATH, rather than abiding to the provided CUDAToolkit_ROOT
. Then, the remainder of the detection logic will base itself upon the found nvcc
and completely ignore the supplied parameter.
According to the documentation, this behavior is expected only when using enable_language(CUDA)
which has not been performed in this project.