diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-11-02 15:26:24 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-11-02 16:33:40 +0100 |
commit | 1bb6779389980d794bac92ca0fef63f3549a93b4 (patch) | |
tree | 27367fff85e4baf900b06efb2b4fa38ff5e04f03 /cmake | |
parent | d3046cbe88c5db3e159076457ae012491c53461e (diff) |
CMake: Let configure guess the compiler from mkspec argument
The arguments -platform, -xplatform and -device determine the mkspec
that's used for the qmake companion files.
If the user specifies a mkspec that indicates usage of clang or icc,
set the respective CMake variables to use one of those compilers.
Fixes: QTBUG-87836
Change-Id: I2b10d819b0eb92a97d7f79672547b1e2d821cf33
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtProcessConfigureArgs.cmake | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index 9614061212..734384bc5e 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -47,6 +47,7 @@ list(TRANSFORM configure_args STRIP) list(TRANSFORM configure_args REPLACE "\\\\" "\\\\\\\\") unset(generator) set(auto_detect_generator TRUE) +set(auto_detect_compiler TRUE) unset(device_options) set_property(GLOBAL PROPERTY UNHANDLED_ARGS "") while(configure_args) @@ -57,6 +58,8 @@ while(configure_args) list(POP_FRONT configure_args generator) elseif(arg STREQUAL "-cmake-use-default-generator") set(auto_detect_generator FALSE) + elseif(arg STREQUAL "-no-guess-compiler") + set(auto_detect_compiler FALSE) elseif(arg STREQUAL "-skip") list(POP_FRONT configure_args qtrepo) push("-DBUILD_${qtrepo}=OFF") @@ -552,6 +555,22 @@ macro(translate_list_input name cmake_var) endif() endmacro() +function(guess_compiler_from_mkspec) + if(NOT auto_detect_compiler) + return() + endif() + string(REGEX MATCH "(^|;)-DQT_QMAKE_TARGET_MKSPEC=\([^;]+\)" m ${cmake_args}) + set(mkspec ${CMAKE_MATCH_2}) + if(mkspec MATCHES "-clang(-|$)") + push("-DCMAKE_C_COMPILER=clang") + push("-DCMAKE_CXX_COMPILER=clang++") + elseif(mkspec MATCHES "-icc(-|$)") + push("-DCMAKE_C_COMPILER=icc") + push("-DCMAKE_CXX_COMPILER=icpc") + endif() + set(cmake_args "${cmake_args}" PARENT_SCOPE) +endfunction() + drop_input(commercial) drop_input(confirm-license) translate_boolean_input(precompile_header BUILD_WITH_PCH) @@ -576,6 +595,7 @@ if(NOT "${INPUT_device}" STREQUAL "") endif() translate_string_input(platform QT_QMAKE_TARGET_MKSPEC) translate_string_input(xplatform QT_QMAKE_TARGET_MKSPEC) +guess_compiler_from_mkspec() translate_string_input(qpa_default_platform QT_QPA_DEFAULT_PLATFORM) translate_list_input(sanitize ECM_ENABLE_SANITIZERS) |