Skip to content

Commit

Permalink
Use separate property to store implicitly detected QT_QML_ROOT_PATHs
Browse files Browse the repository at this point in the history
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 575b8a7

Pick-to: 6.6
Change-Id: Iccadbe1f6ed697a94dba11af3dd054baec8daf9e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit d954d53)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
  • Loading branch information
semlanik authored and Qt Cherry-pick Bot committed Feb 2, 2024
1 parent 98d5d29 commit fa6f278
Showing 1 changed file with 35 additions and 11 deletions.
46 changes: 35 additions & 11 deletions src/corelib/Qt6AndroidMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -988,15 +999,28 @@ 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 "")
foreach(_path IN LISTS _paths)
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()
Expand Down

0 comments on commit fa6f278

Please sign in to comment.