Use separate property to store implicitly detected QT_QML_ROOT_PATHs

Use _qt_internal_qml_root_path when collecting the qml root paths using
_qt_internal_collect_qml_root_paths. The property is only applicable for
Android builds. This suppresses the QTP0002 warning for the cases when
android application has both QML executable and QML library modules.

Amends 575b8a7fa289a2e27984a6c322069f9e1b499024

Pick-to: 6.6
Change-Id: Iccadbe1f6ed697a94dba11af3dd054baec8daf9e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit d954d53c1ddcffda394c4f44663b4c86a61ed452)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexey Edelev 2024-01-31 14:57:36 +01:00 committed by Qt Cherry-pick Bot
parent 98d5d291e7
commit fa6f2783ae

View File

@ -938,26 +938,34 @@ function(_qt_internal_android_format_deployment_paths target)
break()
endif()
endforeach()
if(NOT has_android_paths)
return()
if(has_android_paths)
__qt_internal_setup_policy(QTP0002 "6.6.0"
"Target properties that specify android-specific paths may contain generator\
expressions but they must evaluate to valid JSON strings.\
Check https://doc.qt.io/qt-6/qt-cmake-policy-qtp0002.html for policy details."
)
qt6_policy(GET QTP0002 android_deployment_paths_policy)
endif()
__qt_internal_setup_policy(QTP0002 "6.6.0"
"Target properties that specify android-specific paths may contain generator\
expressions but they must evaluate to valid JSON strings.\
Check https://doc.qt.io/qt-6/qt-cmake-policy-qtp0002.html for policy details."
)
qt6_policy(GET QTP0002 android_deployment_paths_policy)
endif()
if(android_deployment_paths_policy STREQUAL "NEW")
# When building standalone tests or Qt itself we obligate developers to not use
# windows paths when setting QT_* properties below, so their values are used as is when
# generating deployment settings.
string(JOIN "" qml_root_path_genex
"$<GENEX_EVAL:$<TARGET_PROPERTY:${target},QT_QML_ROOT_PATH>>"
"$<"
"$<AND:"
"$<BOOL:$<GENEX_EVAL:$<TARGET_PROPERTY:${target},QT_QML_ROOT_PATH>>>,"
"$<BOOL:$<GENEX_EVAL:$<TARGET_PROPERTY:${target},_qt_internal_qml_root_path>>>"
">:;"
">"
"$<GENEX_EVAL:$<TARGET_PROPERTY:${target},_qt_internal_qml_root_path>>"
)
set_target_properties(${target} PROPERTIES
_qt_native_qml_import_paths
"$<GENEX_EVAL:$<TARGET_PROPERTY:${target},QT_QML_IMPORT_PATH>>"
_qt_android_native_qml_root_paths
"$<GENEX_EVAL:$<TARGET_PROPERTY:${target},QT_QML_ROOT_PATH>>"
"${qml_root_path_genex}"
_qt_android_native_package_source_dir
"$<GENEX_EVAL:$<TARGET_PROPERTY:${target},QT_ANDROID_PACKAGE_SOURCE_DIR>>"
_qt_android_native_extra_plugins
@ -974,6 +982,9 @@ function(_qt_internal_android_format_deployment_paths target)
_qt_internal_android_format_deployment_path_property(${target}
QT_QML_ROOT_PATH _qt_android_native_qml_root_paths)
_qt_internal_android_format_deployment_path_property(${target}
_qt_internal_qml_root_path _qt_android_native_qml_root_paths APPEND)
_qt_internal_android_format_deployment_path_property(${target}
QT_ANDROID_PACKAGE_SOURCE_DIR _qt_android_native_package_source_dir)
@ -988,7 +999,20 @@ endfunction()
# The function converts the value of target property to JSON compatible path and writes the
# result to out_property. Property might be either single value, semicolon separated list or system
# path spec.
# The APPEND argument controls the property is set. The argument should be added after all
# the required arguments.
function(_qt_internal_android_format_deployment_path_property target property out_property)
set(should_append "")
if(ARGC EQUAL 4)
if("${ARGV3}" STREQUAL "APPEND")
set(should_append APPEND)
else()
message(FATAL_ERROR "Unexpected argument ${ARGV3}")
endif()
elseif(ARGC GREATER 4)
message(FATAL_ERROR "Unexpected arguments ${ARGN}")
endif()
get_target_property(_paths ${target} ${property})
if(_paths)
set(native_paths "")
@ -996,7 +1020,7 @@ function(_qt_internal_android_format_deployment_path_property target property ou
file(TO_CMAKE_PATH "${_path}" _path)
list(APPEND native_paths "${_path}")
endforeach()
set_target_properties(${target} PROPERTIES
set_property(TARGET ${target} ${should_append} PROPERTY
${out_property} "${native_paths}")
endif()
endfunction()