summaryrefslogtreecommitdiffstats
path: root/cmake/QtBaseGlobalTargets.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-09-15 12:23:51 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-09-15 20:05:25 +0200
commit67567b8e0d15445aef7ce491930a6c1290122fac (patch)
tree31f6f1ca88299518658e89c466cdb4de6022f928 /cmake/QtBaseGlobalTargets.cmake
parent75c4fd52d126fcdd7dcc211096e90633594f872d (diff)
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>
Diffstat (limited to 'cmake/QtBaseGlobalTargets.cmake')
-rw-r--r--cmake/QtBaseGlobalTargets.cmake11
1 files changed, 9 insertions, 2 deletions
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
index b482c3079f..c5527f5915 100644
--- a/cmake/QtBaseGlobalTargets.cmake
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -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)