CMake: Fix Fortran cross-compilation support
The current CMAKE_CROSSCOMPILING paths lead here to dummy commands "cmake -E env" being emitted that dont seem to do anything even when CROSSCOMPILING_PATH is set (#5720) as it must be followed by an actual command, and not another COMMAND entry:
cmake -E env: no command given
It seems CROSSCOMPILING_PATH is intented to pass environment variables to the emulator. A cleaner way is to set them via a script that actually calls the emulator instead of adding CROSSCOMPILING_PATH to every executable target invocation. Then this script would be passed as CMAKE_CROSSCOMPILING_EMULATOR instead of the emulator itself. A common use-case is to pass WINEPATH to wine so that standard dlls are found when running mingw executables:
#!/bin/sh
mingw_prefix=/usr/i686-w64-mingw32
export WINEPATH=${mingw_prefix}/bin
/usr/bin/wine "$@"
Anyway we can simplify the two paths of the if/else, CMAKE_CROSSCOMPILING_EMULATOR being empty when CMAKE_CROSSCOMPILING is false. Note that we need to use CMAKE_CROSSCOMPILING_EMULATOR explicitely here otherwise it would be omitted by cmake when generator expressions like these, and you cannot always rely on binfmt_misc to forward to the right emulator.
/cc @byrnHDF
Tested with mingw from linux.
[!IMPORTANT] Simplifies CMake cross-compilation by merging paths and using
CMAKE_CROSSCOMPILING_EMULATORconsistently across multiple files.
- Behavior:
- Simplifies cross-compilation by merging
if/elsepaths infortran/src/CMakeLists.txt,fortran/test/CMakeLists.txt, andhl/fortran/src/CMakeLists.txt.- Uses
CMAKE_CROSSCOMPILING_EMULATORconsistently for executing target files.- Commands:
- Removes dummy command
cmake -E env ${CROSSCOMPILING_PATH}in favor ofCMAKE_CROSSCOMPILING_EMULATOR.- Ensures generated files must exist beforehand if
CMAKE_CROSSCOMPILING_EMULATORis not set.- Testing:
- Tested with MinGW from Linux.
This description was created by
for f91fb3c630dd1ff404624b6318ca741fcd7d0e77. You can customize this summary. It will automatically update as commits are pushed.