Update qt_policy and add documentation
- If no version specified, policy version is set to 6.0.0, therefore warnings will be shown, encouraging users to set a policy. - Update qt_policy() documentation - Update qt_standard_project_setup() documentation - Update the policy warning message - Added the missing comment to clarify the extra_code region Task-number: QTBUG-96233 Change-Id: I8358fdeb880a34c96f13fc2a6cbef6afe048c4d6 (cherry picked from commit 95ba368806dc46f9e9efd5381c593f02dfc8da95) Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
d18124f65d
commit
f013f9a125
@ -8,7 +8,9 @@ if(QT_NO_PACKAGE_VERSION_CHECK)
|
|||||||
set(__qt_disable_package_version_check TRUE)
|
set(__qt_disable_package_version_check TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Extra CMake code begin
|
||||||
@extra_code@
|
@extra_code@
|
||||||
|
# Extra CMake code end
|
||||||
|
|
||||||
if((NOT PACKAGE_VERSION_COMPATIBLE) OR PACKAGE_VERSION_UNSUITABLE)
|
if((NOT PACKAGE_VERSION_COMPATIBLE) OR PACKAGE_VERSION_UNSUITABLE)
|
||||||
set(__qt_package_version_incompatible TRUE)
|
set(__qt_package_version_incompatible TRUE)
|
||||||
|
@ -2674,11 +2674,9 @@ function(__qt_internal_setup_policy policy sinceversion policyexplanation)
|
|||||||
set(__QT_INTERNAL_POLICY_${policy} "NEW" PARENT_SCOPE)
|
set(__QT_INTERNAL_POLICY_${policy} "NEW" PARENT_SCOPE)
|
||||||
elseif(NOT "${QT_NO_SHOW_OLD_POLICY_WARNINGS}")
|
elseif(NOT "${QT_NO_SHOW_OLD_POLICY_WARNINGS}")
|
||||||
message(AUTHOR_WARNING
|
message(AUTHOR_WARNING
|
||||||
"Qt policy ${policy} is not set. "
|
"Qt policy ${policy} is not set: "
|
||||||
"Use the qt6_set_policy command to set it and suppress this warning. "
|
"${policyexplanation} "
|
||||||
"You can also silence all policy warnings by setting QT_NO_SHOW_OLD_POLICY_WARNINGS "
|
"Use the qt_policy command to set the policy and suppress this warning.\n"
|
||||||
"to true.\n"
|
|
||||||
"${policyexplanation}"
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
@ -2708,6 +2706,7 @@ macro(qt6_standard_project_setup)
|
|||||||
message(FATAL_ERROR "Unexpected arguments: ${arg_UNPARSED_ARGUMENTS}")
|
message(FATAL_ERROR "Unexpected arguments: ${arg_UNPARSED_ARGUMENTS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Set the Qt CMake policy based on the requested version(s)
|
||||||
set(__qt_policy_check_version "6.0.0")
|
set(__qt_policy_check_version "6.0.0")
|
||||||
if(Qt6_VERSION_MAJOR)
|
if(Qt6_VERSION_MAJOR)
|
||||||
set(__qt_current_version
|
set(__qt_current_version
|
||||||
@ -2718,17 +2717,23 @@ macro(qt6_standard_project_setup)
|
|||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Can not determine Qt version.")
|
message(FATAL_ERROR "Can not determine Qt version.")
|
||||||
endif()
|
endif()
|
||||||
if (__qt_sps_arg_MIN_VERSION)
|
if(__qt_sps_arg_MIN_VERSION)
|
||||||
if ("${__qt_current_version}" VERSION_LESS "${__qt_sps_arg_MIN_VERSION}")
|
if("${__qt_current_version}" VERSION_LESS "${__qt_sps_arg_MIN_VERSION}")
|
||||||
message(FATAL_ERROR "Project required a Qt minimum version of ${__qt_sps_arg_MIN_VERSION}, but current version is only ${__qt_current_version}")
|
message(FATAL_ERROR
|
||||||
|
"Project required a Qt minimum version of ${__qt_sps_arg_MIN_VERSION}, "
|
||||||
|
"but current version is only ${__qt_current_version}.")
|
||||||
endif()
|
endif()
|
||||||
set(__qt_policy_check_version "${__qt_sps_arg_MIN_VERSION}")
|
set(__qt_policy_check_version "${__qt_sps_arg_MIN_VERSION}")
|
||||||
endif()
|
endif()
|
||||||
if (__qt_sps_arg_MAX_VERSION)
|
if(__qt_sps_arg_MAX_VERSION)
|
||||||
if (${__qt_sps_arg_MAX_VERSION} VERSION_LESS ${__qt_sps_arg_MIN_VERSION})
|
if(__qt_sps_arg_MIN_VERSION)
|
||||||
message(FATAL_ERROR "MAX_VERSION must be larger or equal than MIN_VERSION")
|
if(${__qt_sps_arg_MAX_VERSION} VERSION_LESS ${__qt_sps_arg_MIN_VERSION})
|
||||||
|
message(FATAL_ERROR "MAX_VERSION must be larger than or equal to MIN_VERSION.")
|
||||||
|
endif()
|
||||||
|
set(__qt_policy_check_version "${__qt_sps_arg_MAX_VERSION}")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Please specify the MIN_VERSION as well.")
|
||||||
endif()
|
endif()
|
||||||
set(__qt_policy_check_version "${__qt_sps_arg_MAX_VERSION}")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# All changes below this point should not result in a change to an
|
# All changes below this point should not result in a change to an
|
||||||
|
@ -18,35 +18,49 @@
|
|||||||
|
|
||||||
\badcode
|
\badcode
|
||||||
qt_policy(
|
qt_policy(
|
||||||
[SET policy behavior]
|
[SET <policy_name> behavior]
|
||||||
[GET policy variable]
|
[GET <policy_name> <variable>]
|
||||||
)
|
)
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
\versionlessCMakeCommandsNote qt6_policy()
|
\versionlessCMakeCommandsNote qt6_policy()
|
||||||
|
|
||||||
\section1 Description
|
\section1 Description
|
||||||
|
|
||||||
This command has two modes:
|
This command has two modes:
|
||||||
|
|
||||||
\list
|
\list
|
||||||
\li When the \c{SET} keyword is used, this command can be used to opt in to
|
\li When the \c{SET} keyword is used, this command can be used to opt in to
|
||||||
behavior changes in Qt's CMake API, or to explicitly opt out of them.
|
behavior changes in Qt's CMake API, or to explicitly opt out of them.
|
||||||
\li When the \c{GET} keyword is used, \c{variable} is set to the current
|
\li When the \c{GET} keyword is used, \c{<variable>} is set to the current
|
||||||
value for the policy.
|
behavior for the policy, i.e. \c OLD or \c NEW.
|
||||||
\endlist
|
\endlist
|
||||||
\c{policyname} must be the name of a Qt cmake policy. Using an unknown policy
|
|
||||||
is an error; code supporting older Qt versions should check with
|
\c{<policy_name>} must be the name of one of the \l{Qt CMake policies}.
|
||||||
|
Policy names have the form of \c{QTP<NNNN>} where <NNNN> is
|
||||||
|
an integer specifying the index of the policy. Using an invalid policy
|
||||||
|
name results in an error.
|
||||||
|
|
||||||
|
Code supporting older Qt versions can check the existence of a policy by
|
||||||
|
checking the value of the \c{QT_KNOWN_POLICY_<policy_name>} variable before
|
||||||
|
getting the value of \c <policy_name> or setting its behavior.
|
||||||
|
|
||||||
\badcode
|
\badcode
|
||||||
if(QT_KNOWN_POLICY_<policy_name>)
|
if(QT_KNOWN_POLICY_<policy_name>)
|
||||||
|
qt_policy(SET <policy_name> NEW)
|
||||||
|
endif()
|
||||||
\endcode
|
\endcode
|
||||||
whether the policy exists before querying or setting it.
|
|
||||||
|
|
||||||
\c{behavior} can
|
You can set \c behavior to one of the following options:
|
||||||
either be
|
|
||||||
\list
|
\list
|
||||||
\li \c{NEW} to opt into the new behavior, or
|
\li \c{NEW} to opt into the new behavior
|
||||||
\li \c{OLD} to explicitly opt-out of it.
|
\li \c{OLD} to explicitly opt-out of it
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
|
\note The \c{OLD} behavior of a policy is deprecated, and may
|
||||||
|
be removed in the future.
|
||||||
|
|
||||||
\sa qt_standard_project_setup
|
\sa qt_standard_project_setup
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
\badcode
|
\badcode
|
||||||
qt_standard_project_setup(
|
qt_standard_project_setup(
|
||||||
[MIN_VERSION policy_min]
|
[MIN_VERSION <version>]
|
||||||
[MAX_VERSION policy_max]
|
[MAX_VERSION <version>]
|
||||||
)
|
)
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
@ -50,15 +50,14 @@ have been defined. It does the following things:
|
|||||||
Qt-internal targets in this folder.
|
Qt-internal targets in this folder.
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
Moreover, since Qt 6.5 it can be used to change the default behavior of Qt's CMake
|
Since Qt 6.5, it is possible to change the default behavior of Qt's CMake
|
||||||
API, by opting in to changes from newer Qt versions. If \c{MIN_VERSION} is
|
API by opting in to changes from newer Qt versions. If \c{MIN_VERSION} is
|
||||||
specified, all suggested changes introduced in Qt up to \c{MIN_VERSION} are enabled,
|
specified, all suggested changes introduced in Qt up to \c{MIN_VERSION} are enabled,
|
||||||
and using an older Qt version will result in an error.
|
and using an older Qt version will result in an error.
|
||||||
If additionally \c{MAX_VERSION} has been specified, any new changes introduced
|
If additionally \c{MAX_VERSION} has been specified, any new changes introduced
|
||||||
in versions up to \c{MAX_VERSION} are also enabled (but using an older Qt
|
in versions up to \c{MAX_VERSION} are also enabled (but using an older Qt
|
||||||
version is not an error).
|
version is not an error). This is similar to CMake's policy concept
|
||||||
This is similar to CMake's policy concept (compare \l{cmake_policy}).
|
(compare \l{cmake_policy}).
|
||||||
|
|
||||||
|
|
||||||
On platforms that support \c{RPATH} (other than Apple platforms), two values
|
On platforms that support \c{RPATH} (other than Apple platforms), two values
|
||||||
are appended to the \c{CMAKE_INSTALL_RPATH} variable by this command.
|
are appended to the \c{CMAKE_INSTALL_RPATH} variable by this command.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user