Introduce QTP0002 policy for android-specific target properties

The policy controls the behavior of the android-specific target
properties that specify paths.

The OLD behavior of this policy doesn't allow generator expressions
in the target properties that specify android-specific paths but
implicitly converts the specified paths to the valid JSON strings.

The NEW behavior of this policy allows using generator expressions
in the target properties that specify android-specific paths but they
must evaluate to valid JSON strings.

[ChangeLog][Android] Target properties that specify android-specific
paths now support generator expressions, but these generator
expressions must be evaluated to valid JSON strings. The behavior is
controlled by the policy QTP0002. The OLD policy behavior is deprecated
and the NEW behavior is preferred for use.

Fixes: QTBUG-107988
Change-Id: I8484c4b5d5ace25eb04f8bc8a79ddbaa9a79b19b
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2023-03-09 13:10:36 +01:00
parent a92a2a050a
commit c4debab927
3 changed files with 74 additions and 1 deletions

View File

@ -337,6 +337,8 @@ qt_internal_add_module(Core
"${CMAKE_CURRENT_SOURCE_DIR}/Qt6CoreDeploySupport.cmake"
"${config_build_dir}/QtInstallPaths.cmake"
${corelib_extra_cmake_files}
POLICIES
QTP0002
)
_qt_internal_setup_deploy_support()

View File

@ -881,7 +881,14 @@ endfunction()
# It doesn't overwrite public properties, but instead writes formatted values to internal
# properties.
function(_qt_internal_android_format_deployment_paths target)
if(QT_BUILD_STANDALONE_TESTS OR QT_BUILDING_QT)
__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)
if(QT_BUILD_STANDALONE_TESTS OR QT_BUILDING_QT OR
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.

View File

@ -0,0 +1,64 @@
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qt-cmake-policy-qtp0002.html
\ingroup qt-cmake-policies
\title QTP0002
\keyword qt_cmake_policy_qtp0002
\summary {Target properties that specify Android-specific paths may contain generator expressions.}
This policy was introduced in Qt 6.6. It changes the processing of target
properties that specify Android-specific paths:
\list
\li \l QT_QML_IMPORT_PATH
\li \l QT_QML_ROOT_PATH
\li \l QT_ANDROID_PACKAGE_SOURCE_DIR
\li \l QT_ANDROID_EXTRA_PLUGINS
\li \l QT_ANDROID_EXTRA_LIBS
\endlist
The \c OLD behavior of this policy doesn't allow generator expressions in the
target properties that specify Android-specific paths but implicitly converts
the specified paths to valid JSON strings.
The \c NEW behavior of this policy allows using generator expressions in the
target properties that specify Android-specific paths, but they must evaluate to
valid JSON strings.
The following value of the \l QT_ANDROID_EXTRA_PLUGINS property is converted to
a valid JSON string if you set the policy to OLD, but leads to an error if the
policy is set to NEW:
\badcode
set_target_properties(
QT_ANDROID_EXTRA_PLUGINS "\\path\\to\\MyPlugin.so"
)
\endcode
If the policy is set to NEW for the above example, the resulting JSON string in
the deployment settings file will contain escaped symbols instead of path
separators.
Generator expressions are only supported if the policy is set to NEW, so the
OLD behavior generates a malformed deployment settings file with the following
code:
\badcode
set_target_properties(
QT_ANDROID_EXTRA_PLUGINS "$<TARGET_FILE_DIR:MyPlugin>"
)
\endcode
This property value works as expected with both OLD and NEW policy values:
\badcode
set_target_properties(
QT_ANDROID_EXTRA_PLUGINS "/path/to/MyPlugin.so"
)
\endcode
\note The \c{OLD} behavior of a policy is deprecated, and may
be removed in the future.
\sa qt_policy, {Qt CMake policies}
*/