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>
This commit is contained in:
parent
d3046cbe88
commit
1bb6779389
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user