CMake: Prefer target arch qmltestrunner when searching for it
Currently qmltestrunner is built as a tool, instead of an app. That means that for most cross-compiling platforms (aside from Yocto), the build system will look for a host binary when referring to the qmltestrunner target. We want to look for the target platform binary instead. Switch the code around to prefer looking for the target platform binary via find_program, before falling back to referring to it by target name. In the future when we change qmltestrunner to be an app, and also expose its target platform binary as a target name, this should not be needed anymore, and we could rely solely on the target name. Amends 9edcc4690665496c2b6f15876b3979487dbad22a Task-number: COIN-1211 Task-number: QTBUG-137005 Change-Id: If2eb93d8832a17aae3d0648d1d0f5997805796fa Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
6f8431b930
commit
c2f7004204
@ -753,29 +753,38 @@ function(qt_internal_add_test name)
|
||||
endif()
|
||||
else()
|
||||
if(arg_QMLTEST AND NOT arg_SOURCES)
|
||||
if(TARGET ${QT_CMAKE_EXPORT_NAMESPACE}::qmltestrunner)
|
||||
# TODO: fallback to support qtr as 'tool', remove when changes in qtdeclarative are in
|
||||
set(qmltestrunner_executable ${QT_CMAKE_EXPORT_NAMESPACE}::qmltestrunner)
|
||||
elseif(TARGET qmltestrunner)
|
||||
set(qmltestrunner_executable qmltestrunner)
|
||||
else()
|
||||
set(qt_additional_libexec_paths "")
|
||||
if(DEFINED QT_ADDITIONAL_PACKAGES_PREFIX_PATH)
|
||||
foreach(additional_prefix IN LISTS QT_ADDITIONAL_PACKAGES_PREFIX_PATH)
|
||||
set(additional_libexec "${additional_prefix}/${QT6_INSTALL_LIBEXECS}")
|
||||
list(PREPEND qt_additional_libexec_paths "${additional_libexec}")
|
||||
endforeach()
|
||||
endif()
|
||||
find_program(qmltestrunner_executable
|
||||
NAMES qmltestrunner qmltestrunner.exe
|
||||
PATHS "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_LIBEXECS}"
|
||||
${qt_additional_libexec_paths}
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if(NOT qmltestrunner_executable)
|
||||
message(FATAL_ERROR "qmltestrunner not found.")
|
||||
endif()
|
||||
set(qt_additional_libexec_paths "")
|
||||
|
||||
if(DEFINED QT_ADDITIONAL_PACKAGES_PREFIX_PATH)
|
||||
foreach(additional_prefix IN LISTS QT_ADDITIONAL_PACKAGES_PREFIX_PATH)
|
||||
set(additional_libexec "${additional_prefix}/${QT6_INSTALL_LIBEXECS}")
|
||||
list(PREPEND qt_additional_libexec_paths "${additional_libexec}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# First look for the scanner in the target qt libexec dir. We prefer this one
|
||||
# over the tool target which might be for the host platform.
|
||||
find_program(qmltestrunner_executable
|
||||
NAMES qmltestrunner qmltestrunner.exe
|
||||
PATHS "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_LIBEXECS}"
|
||||
${qt_additional_libexec_paths}
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
# If we don't find it in the paths, fallback to using target names.
|
||||
if(NOT qmltestrunner_executable
|
||||
AND TARGET "${QT_CMAKE_EXPORT_NAMESPACE}::qmltestrunner")
|
||||
set(qmltestrunner_executable ${QT_CMAKE_EXPORT_NAMESPACE}::qmltestrunner)
|
||||
endif()
|
||||
|
||||
if(NOT qmltestrunner_executable AND TARGET qmltestrunner)
|
||||
set(qmltestrunner_executable qmltestrunner)
|
||||
endif()
|
||||
|
||||
if(NOT qmltestrunner_executable)
|
||||
message(FATAL_ERROR "qmltestrunner not found.")
|
||||
endif()
|
||||
|
||||
set(test_working_dir "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(test_executable "${qmltestrunner_executable}")
|
||||
else()
|
||||
|
Loading…
x
Reference in New Issue
Block a user