try_compile fails when used within find_program
I am trying to cross compile from Linux x86-64 gcc 6.x.x to Linux armv7. To that end, I use the following toolchain file (excerpt):
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(triple arm-linux-gnueabihf)
find_program(
CMAKE_C_COMPILER
NAMES ${triple}-gcc
PATHS ${tools}/bin REQUIRED
NO_DEFAULT_PATH)
It fails with:
CMake Error at /home/rwi/projects/ssw/ExtOpenSSL/xilinx_armv7.cmake:73 (find_program):
Could not find CMAKE_CXX_COMPILER using the following names:
arm-linux-gnueabihf-g++
Call Stack (most recent call first):
/home/rwi/projects/ssw/ExtOpenSSL/buildDir/Release/CMakeFiles/3.24.0/CMakeSystem.cmake:6 (include)
/home/rwi/projects/ssw/ExtOpenSSL/buildDir/Release/CMakeFiles/CMakeTmp/CMakeLists.txt:3 (project)
Called from: [3] /home/rwi/projects/ssw/ExtOpenSSL/BuildTools/cmake/share/cmake-3.24/Modules/CMakeDetermineCompilerABI.cmake
[2] /home/rwi/projects/ssw/ExtOpenSSL/BuildTools/cmake/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake
[1] /home/rwi/projects/ssw/ExtOpenSSL/CMakeLists.txt
CMake Error at BuildTools/cmake/share/cmake-3.24/Modules/CMakeDetermineCompilerABI.cmake:57 (try_compile):
Failed to configure test project build system.
Call Stack (most recent call first):
BuildTools/cmake/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)
CMakeLists.txt:11 (project)
Called from: [3] /home/rwi/projects/ssw/ExtOpenSSL/BuildTools/cmake/share/cmake-3.24/Modules/CMakeDetermineCompilerABI.cmake
[2] /home/rwi/projects/ssw/ExtOpenSSL/BuildTools/cmake/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake
[1] /home/rwi/projects/ssw/ExtOpenSSL/CMakeLists.txt
-- Configuring incomplete, errors occurred!
It works though when I simply set the compiler variable:
set(CMAKE_C_COMPILER ${tools}/bin/${triple}-gcc)
This looks like a bug to me.