[PATCH] [CMAKE] Allow a toolchain file for the host when cross-compiling

The current behavior is to not specify any toolchain and invoke CMake
without additional arguments for configuring the NATIVE portion of the
build. However, CMake will actually set the CC, CXX, and FC
environment variables to full paths of the compilers in the
CMAKE_{C,CXX,Fortran}_COMPILER CMake variables inside the CMake process.
This results in those variables being propagated to any execute_process
calls so without explicitly providing a separate toolchain file, the
configure step for the NATIVE host will pick up the compilers used by
the cross-compile toolchain intended for the target CPU.

0001-CMAKE-Allow-a-toolchain-file-for-the-host-when-cross.patch (1.71 KB)

Scratch the first one, it’s got some typos. This is the one I meant to upload. I’ve been using it for cross-compiling on Cray.

0001-CMAKE-Allow-a-toolchain-file-for-the-host-when-cross.patch (2.63 KB)

Sorry for the delay in responding to this, I’m WAY behind on my email.

The patch looks good to me. Thanks for doing this, it is a nice improvement over the existing code!