FindCUDAToolkit: Support cross-compilation to sbsa-linux

Fixes #24192
This commit is contained in:
Robert Maynard
2023-01-11 11:26:44 -05:00
parent e60fa80fbe
commit 743d4181b4
2 changed files with 24 additions and 17 deletions

View File

@@ -0,0 +1,4 @@
FindCUDAToolkit-arm64-sbsa
--------------------------
* The :module:`FindCUDAToolkit` gained support for the `sbsa-linux` cross compilation target

View File

@@ -795,32 +795,35 @@ endif()
if(CMAKE_CROSSCOMPILING)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
# Support for NVPACK
set(CUDAToolkit_TARGET_NAME "armv7-linux-androideabi")
set(CUDAToolkit_TARGET_NAMES "armv7-linux-androideabi")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
set(CUDAToolkit_TARGET_NAME "armv7-linux-gnueabihf")
set(CUDAToolkit_TARGET_NAMES "armv7-linux-gnueabihf")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
if(ANDROID_ARCH_NAME STREQUAL "arm64")
set(CUDAToolkit_TARGET_NAME "aarch64-linux-androideabi")
set(CUDAToolkit_TARGET_NAMES "aarch64-linux-androideabi")
elseif (CMAKE_SYSTEM_NAME STREQUAL "QNX")
set(CUDAToolkit_TARGET_NAME "aarch64-qnx")
set(CUDAToolkit_TARGET_NAMES "aarch64-qnx")
else()
set(CUDAToolkit_TARGET_NAME "aarch64-linux")
endif(ANDROID_ARCH_NAME STREQUAL "arm64")
set(CUDAToolkit_TARGET_NAMES "aarch64-linux" "sbsa-linux")
endif()
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(CUDAToolkit_TARGET_NAME "x86_64-linux")
set(CUDAToolkit_TARGET_NAMES "x86_64-linux")
endif()
if(EXISTS "${CUDAToolkit_ROOT_DIR}/targets/${CUDAToolkit_TARGET_NAME}")
set(CUDAToolkit_TARGET_DIR "${CUDAToolkit_ROOT_DIR}/targets/${CUDAToolkit_TARGET_NAME}")
# add known CUDA target root path to the set of directories we search for programs, libraries and headers
list(PREPEND CMAKE_FIND_ROOT_PATH "${CUDAToolkit_TARGET_DIR}")
foreach(CUDAToolkit_TARGET_NAME IN LISTS CUDAToolkit_TARGET_NAMES)
if(EXISTS "${CUDAToolkit_ROOT_DIR}/targets/${CUDAToolkit_TARGET_NAME}")
set(CUDAToolkit_TARGET_DIR "${CUDAToolkit_ROOT_DIR}/targets/${CUDAToolkit_TARGET_NAME}")
# add known CUDA target root path to the set of directories we search for programs, libraries and headers
list(PREPEND CMAKE_FIND_ROOT_PATH "${CUDAToolkit_TARGET_DIR}")
# Mark that we need to pop the root search path changes after we have
# found all cuda libraries so that searches for our cross-compilation
# libraries work when another cuda sdk is in CMAKE_PREFIX_PATH or
# PATh
set(_CUDAToolkit_Pop_ROOT_PATH True)
endif()
# Mark that we need to pop the root search path changes after we have
# found all cuda libraries so that searches for our cross-compilation
# libraries work when another cuda sdk is in CMAKE_PREFIX_PATH or
# PATh
set(_CUDAToolkit_Pop_ROOT_PATH True)
break()
endif()
endforeach()
endif()
# If not already set we can simply use the toolkit root or it's a scattered installation.