Make sure that QT_QMAKE_TARGET_MKSPEC is not empty

If target platform is not detected the QT_QMAKE_TARGET_MKSPEC
variable remains empty. We need to check this explicitly.
Also store the default QT_QMAKE_TARGET_MKSPEC variable in the target
toolchain file. This is useful if users want to build repos
one-by-one or build standalone tests without the need to specify
the QT_QMAKE_TARGET_MKSPEC each time when configuring new repo or
tests.

Task-number: QTBUG-113630
Pick-to: 6.5 6.2
Change-Id: I57dfc6c97752a645868d77998d8f52e16bdfd5c8
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexey Edelev 2023-05-19 13:15:43 +02:00
parent 604af4d5bc
commit e5d7a3920a
2 changed files with 19 additions and 3 deletions

View File

@ -376,15 +376,23 @@ else()
set(QT_QMAKE_HOST_MKSPEC "${QT_QMAKE_TARGET_MKSPEC}")
endif()
if(NOT EXISTS "${QT_MKSPECS_DIR}/${QT_QMAKE_TARGET_MKSPEC}")
if(NOT QT_QMAKE_TARGET_MKSPEC OR NOT EXISTS "${QT_MKSPECS_DIR}/${QT_QMAKE_TARGET_MKSPEC}")
if(NOT QT_QMAKE_TARGET_MKSPEC)
set(reason "Platform is not detected. Please make sure your build environment is configured"
" properly or specify it manually using QT_QMAKE_TARGET_MKSPEC variable and one of the"
" known platforms.")
else()
set(reason "Unknown platform ${QT_QMAKE_TARGET_MKSPEC}")
endif()
file(GLOB known_platforms
LIST_DIRECTORIES true
RELATIVE "${QT_MKSPECS_DIR}"
"${QT_MKSPECS_DIR}/*"
)
list(JOIN known_platforms "\n " known_platforms)
message(FATAL_ERROR "Unknown platform ${QT_QMAKE_TARGET_MKSPEC}\n\
Known platforms:\n ${known_platforms}")
message(FATAL_ERROR "${reason}\n"
"Known platforms:\n ${known_platforms}")
endif()
if(NOT DEFINED QT_DEFAULT_PLATFORM_DEFINITIONS)

View File

@ -31,6 +31,14 @@ set(__qt_chainload_toolchain_file \"\${__qt_initially_configured_toolchain_file}
list(APPEND init_platform "set(CMAKE_SYSTEM_PROCESSOR arm64 CACHE STRING \"\")")
endif()
if(QT_QMAKE_TARGET_MKSPEC)
list(APPEND init_platform
"if(NOT QT_QMAKE_TARGET_MKSPEC)"
" set(QT_QMAKE_TARGET_MKSPEC ${QT_QMAKE_TARGET_MKSPEC} CACHE STRING \"\")"
"endif()"
)
endif()
if("${QT_QMAKE_TARGET_MKSPEC}" STREQUAL "linux-g++-32" AND NOT QT_NO_AUTO_DETECT_LINUX_X86)
set(__qt_toolchain_common_flags_init "-m32")