CMake: Conditionally set compiler in generated toolchain file

Public consumers of the qt toolchain file will most likely not have
their compilers in the same location where they were on the Qt build
machine.

Only set the compiler paths if none was set already, and the paths
actually exist.

This seems to become a trend in the generated toolchain file, and is
only a stop-gap solution.

A proper solution (two different toolchain files) may follow.

Task-number: QTBUG-83999
Change-Id: I7a603af447333a45c65b98e299ee109932d16517
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2020-09-15 12:23:51 +02:00
parent 75c4fd52d1
commit 67567b8e0d

View File

@ -162,8 +162,15 @@ if(DEFINED QT_EMBED_TOOLCHAIN_COMPILER)
endif()
endif()
if(__qt_embed_toolchain_compilers)
list(APPEND init_platform "set(CMAKE_CXX_COMPILER \"${CMAKE_CXX_COMPILER}\" CACHE STRING \"\")")
list(APPEND init_platform "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\" CACHE STRING \"\")")
list(APPEND init_platform "
set(__qt_initial_c_compiler \"${CMAKE_C_COMPILER}\")
set(__qt_initial_cxx_compiler \"${CMAKE_CXX_COMPILER}\")
if(NOT DEFINED CMAKE_C_COMPILER AND EXISTS \"\${__qt_initial_c_compiler}\")
set(CMAKE_C_COMPILER \"\${__qt_initial_c_compiler}\" CACHE STRING \"\")
endif()
if(NOT DEFINED CMAKE_CXX_COMPILER AND EXISTS \"\${__qt_initial_cxx_compiler}\")
set(CMAKE_CXX_COMPILER \"\${__qt_initial_cxx_compiler}\" CACHE STRING \"\")
endif()")
endif()
unset(__qt_embed_toolchain_compilers)