CUDA: Toolkit detection fails
With current CMake 3.18.0-rc2 the CUDA toolkit detection fails in my case:
$ CUDACXX=/usr/local/cuda-9.2/bin/nvcc cmake -B build -G Ninja -DCUDA_TOOLKIT_ROOT=/usr/local/cuda-9.2/ -DCMAKE_TOOLCHAIN_FILE=${CI_PROJECT_DIR}/Toolchain-aarch64.cmake ${CI_PROJECT_DIR}
-- The CXX compiler identification is GNU 7.4.0
-- The CUDA compiler identification is NVIDIA 9.2.148
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/aarch64-linux-gnu-g++-7 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /usr/local/cuda-9.2/bin/nvcc - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- Unable to find cuda_runtime.h in "/include" for CUDAToolkit_INCLUDE_DIR.
-- Unable to find cudart library.
CMake Error at /usr/local/cmake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
Could NOT find CUDAToolkit (missing: CUDAToolkit_INCLUDE_DIR CUDA_CUDART)
(found version "10.2.89")
Call Stack (most recent call first):
/usr/local/cmake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
/usr/local/cmake/share/cmake-3.18/Modules/FindCUDAToolkit.cmake:727 (find_package_handle_standard_args)
CUDA/CMakeLists.txt:9 (find_package)
I do have 2 CUDA versions installed 10.2 as well as 9.2. Although the correct CUDA compiler version is detected (9.2.148), detecting the CUDA toolkit fails, apparently version 10.2.89.
I assume that the CUDA version is checked again and as CUDA defaults to 10.2 (/usr/local/cuda -> cuda-10.2
) there is a version mismatch.
I bisected this problem to ec59fb6c from !4828 (merged)