FindCUDAToolkit.cmake must support cross-compiling
Most recent FindCUDAToolkit.cmake on master (last change: 6e474364) can't find cuda tk headers and libraries when cmake is cross-compiling. The logic is present in FindCUDA.cmake but wasn't ported to the new module.
From my tests, it suffices to add the following just before the libs and headers are found:
if(CMAKE_CROSSCOMPILING)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
# Support for NVPACK
set (CUDAToolkit_TARGET_NAME "armv7-linux-androideabi")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
# Support for arm cross compilation
set(CUDAToolkit_TARGET_NAME "armv7-linux-gnueabihf")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
# Support for aarch64 cross compilation
if (ANDROID_ARCH_NAME STREQUAL "arm64")
set(CUDAToolkit_TARGET_NAME "aarch64-linux-androideabi")
else()
set(CUDAToolkit_TARGET_NAME "aarch64-linux")
endif (ANDROID_ARCH_NAME STREQUAL "arm64")
endif()
if (EXISTS "${CUDAToolkit_ROOT_DIR}/targets/${CUDAToolkit_TARGET_NAME}")
set(CUDAToolkit_TARGET_DIR "${CUDAToolkit_ROOT_DIR}/targets/${CUDAToolkit_TARGET_NAME}" CACHE PATH "CUDA Toolkit target location.")
mark_as_advanced(CUDAToolkit_TARGET_DIR)
endif()
# add known CUDA target root path to the set of directories we search for programs, libraries and headers
set(CMAKE_FIND_ROOT_PATH "${CUDAToolkit_TARGET_DIR};${CMAKE_FIND_ROOT_PATH}")
else()
set(CUDAToolkit_TARGET_DIR ${CUDAToolkit_ROOT_DIR})
endif()
Edited by Rodolfo Schulz de Lima