Some more digging today.
I've tried a different way cause yours didn't work for me:
1. Installed latest linaro:
sudo mkdir -p /opt/linaro
sudo chmod -R 775 /opt/linaro
sudo chown -R $USER /opt/linaro
cd /opt/linaro
tar -xf gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu.tar.xz
2. Made a copy of the target rootfs on the host. I use that script that I copy in the jetpack installation directory:
cd ~/jetpack-3.1/
cat > updatesysroot.sh <<EOL
#!/bin/bash
ip=${1:-192.168.1.100}
rsync -aAXv --delete \
--exclude={"/bin/*",\
"/boot/*",\
"/dev/*",\
"/etc/*",\
"/home/*",\
"/lost+found",\
"/media/*",\
"/mnt/*",\
"/opt/*",\
"/proc/*",\
"/root/*",\
"/run/*",\
"/sbin/*",\
"/snap/*",\
"/srv/*",\
"/sys/*",\
"/tmp/*",\
"/var/*",\
"/usr/3rdparty/*",\
"/usr/games/*",\
"/usr/local/bin/*",\
"/usr/local/etc/*",\
"/usr/local/games/*",\
"/usr/local/man/*",\
"/usr/local/sbin/*",\
"/usr/local/share/*",\
"/usr/local/src/*",\
"/usr/sbin/*",\
"/usr/src/*",\
"/usr/bin/*",\
"/usr/libaarch64-linux-gnu/*",\
"/usr/locale/*",\
"/usr/share/*"} \
-e ssh ubuntu@$ip:/ target_rootfs
EOL
chmod +x updatesysroot.sh
./updatesysroot.sh
3. Patched /usr/share/cmake-3.5/Modules/FindCUDA.cmake
macro(cuda_find_library_local_first_with_path_ext _var _names _doc _path_ext )
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
# CUDA 3.2+ on Windows moved the library directories, so we need the new
# and old paths.
set(_cuda_64bit_lib_dir "${_path_ext}lib/x64" "${_path_ext}lib64" "${_path_ext}libx64" )
endif()
if(CMAKE_CROSSCOMPILING AND (ARM OR AARCH64))
set(_cuda_cross_arm_lib_dir "${_path_ext}lib/stubs")
endif()
if(CUDA_VERSION VERSION_GREATER "6.0")
set(_cuda_static_lib_names "")
foreach(name ${_names})
list(APPEND _cuda_static_lib_names "${name}_static")
endforeach()
endif()
# CUDA 3.2+ on Windows moved the library directories, so we need to new
# (lib/Win32) and the old path (lib).
find_library(${_var}
NAMES ${_names} ${_cuda_static_lib_names}
PATHS "${CUDA_TOOLKIT_TARGET_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}"
ENV CUDA_PATH
ENV CUDA_LIB_PATH
PATH_SUFFIXES ${_cuda_64bit_lib_dir} "${_path_ext}lib/Win32" "${_path_ext}lib" "${_path_ext}libWin32"
DOC ${_doc}
NO_DEFAULT_PATH
)
# Search default search paths, after we search our own set of paths.
find_library(${_var}
NAMES ${_names}
PATHS "/usr/lib/nvidia-current"
DOC ${_doc}
)
endmacro()
4. I modified TegraCrossToolchain.cmake as:
set(COMPILER_PATH /opt/linaro/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu)
set(CMAKE_SYSROOT /home/damien/jetpack-3.1/target_rootfs)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_C_COMPILER ${COMPILER_PATH}/bin/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${COMPILER_PATH}/bin/aarch64-linux-gnu-g++)
set(CUDA_VERSION 8.0)
set(CUDA_TOOLKIT_TARGET_DIR ${CMAKE_SYSROOT}/usr/local/cuda-${CUDA_VERSION})
set(CUDA_TOOLKIT_TARGET_DIR_INTERNAL ${CMAKE_SYSROOT}/usr/local/cuda-${CUDA_VERSION})
set(CUDA_TOOLKIT_ROOT_DIR /usr/local/cuda-${CUDA_VERSION})
set(CUDA_TOOLKIT_ROOT_DIR_INTERNAL /usr/local/cuda-${CUDA_VERSION})
5. My CMake command looks like this:
cd build_cross