FindCUDAToolkit: Prefer location of CMAKE_CUDA_COMPILER even when CUDA language not enabled
I have several CUDA versions installed under /usr/local
, one of which is linked to by /usr/local/cuda
as is customary. Occasionally I force the use of one of them by specifying -DCMAKE_CUDA_COMPILER
in the invocation of CMake; and this works. However - if I perform find_package(CUDAToolkit)
, before actually enabling the CUDA language (e.g. in some test programs) - I get /usr/local/cuda
as the found toolkit location, even though that's a different version than the CUDA compiler I've chosen.
Now, there's the question of whether it is at all legitimate to use a CUDA compiler of version X and find the CUDA toolkit at version Y != X ; but putting that aside: the FindCUDAToolkit module should prefer a toolkit version corresponding to the specified compiler's, and at the very least start its search around the compiler's location, i.e. if I use /usr/local/cuda-9.0/bin/nvcc
, it should definitely try /usr/local/cuda-9.0
before trying /usr/local/cuda
. That's how it works after enabling the language, but it should also work the same before enabling it.