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) diff --git a/config_help.txt b/config_help.txt index e790c61e7d..1d4c73ec95 100644 --- a/config_help.txt +++ b/config_help.txt @@ -90,6 +90,8 @@ Build options: CMake instead of auto-detecting one. -cmake-use-default-generator ... Turn off auto-detection of the CMake build system generator. + -no-guess-compiler ... Do not guess the compiler from the target mkspec. + Only applies to the CMake build. -release ............. Build Qt with debugging turned off [yes] -debug ............... Build Qt with debugging turned on [no] -debug-and-release ... Build two versions of Qt, with and without