Cross compiling CUDA to Tegra platform invokes the wrong linker in try_compile()
Using cmake 3.18.1 on Ubuntu trusty amd64. The target is armhf on Tegra X1.
I have a small project (I've attached the files, although not the source because I used the NVIDIA sample software "simplePrintf"). The layout is a source directory called "ASP" and a sibling directory for build called "build"
The problem is that the first invocation of
cmake -DCMAKE_TOOLCHAIN_FILE=TX1_toolchain.cmake ../ASP
fails because during try_compile() for the CUDA toolchain it uses the system's /usr/bin/g++ for linking instead of the cross-compile tool (arm-linux-gnueabihf-g++-4.8). The object file that it attempts to link is 32bit ELF for armhf.
The second time I invoke the same command
cmake -DCMAKE_TOOLCHAIN_FILE=TX1_toolchain.cmake ../ASP
it (fortunately) skips the try_compile step for CUDA and succeeds to generate the build system.
The build also works:
cmake --build .
produces the right executable which runs correctly on the target.
A c++ "Hello world" program correctly runs completely through.
It looks either cmake -E cmake_link_script ...
is making a mistake, or I am, but it's a really small test example.