qt_policy
Modify the default behavior of Qt's CMake API.
The command is defined in the Core component of the Qt6 package, which can be loaded like so:
find_package(Qt6 REQUIRED COMPONENTS Core)
This command was introduced in Qt 6.5.
Synopsis
qt_policy(
[SET policy behavior]
[GET policy variable]
)
If versionless commands are disabled, use qt6_policy() instead. It supports the same set of arguments as this command.
Description
This command has two modes:
- When the
SETkeyword 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. - When the
GETkeyword is used,variableis set to the current value for the policy.
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
if(QT_KNOWN_POLICY_<policy_name>)
whether the policy exists before querying or setting it.
behavior can either be
NEWto opt into the new behavior, orOLDto explicitly opt-out of it.
See also qt_standard_project_setup.