CMake 变量参考

Qt build variables

When building Qt you can use CMake variables to control the build result.

变量 描述
QT_HOST_PATH Location of the host Qt installation from which host tools may be used during another Qt build, either a regular one or a cross-compiling one.
QT_FORCE_BUILD_TOOLS Forces building tools even if host tools have already been found. Useful when cross-compiling Qt to ensure the SDK has cross-built tools.
QT_FORCE_FIND_TOOLS Uses Qt tools from the pre-built Qt in QT_HOST_PATH when you do not cross-compile. The variable only takes effect if QT_FORCE_BUILD_TOOLS 被设为 ON . Otherwise QT_FORCE_FIND_TOOLS does not affect the default behavior.

模块变量

Qt 模块的加载采用 find_package 设置各种变量。

注意: 您很少需要直接访问这些变量。像链接到模块的常见任务,应透过每个模块定义的库目标来完成。

例如, find_package(Qt6 COMPONENTS Widgets) ,当成功时,使以下变量变得可用:

变量 描述
Qt6Widgets_COMPILE_DEFINITIONS 要使用的编译定义列表,当针对库构建时。
Qt6Widgets_DEFINITIONS 要使用的定义列表,当针对库构建时。
Qt6Widgets_EXECUTABLE_COMPILE_FLAGS 要使用的标志字符串,当针对库构建可执行文件时。
Qt6Widgets_FOUND 描述是否成功找到模块的布尔。
Qt6Widgets_INCLUDE_DIRS 要使用的 include (包括) 目录列表,当针对库构建时。
Qt6Widgets_LIBRARIES 模块导入目标的名称: Qt6::Widgets
Qt6Widgets_PRIVATE_INCLUDE_DIRS 要使用的私有 include (包括) 目录列表,当针对库构建并使用私有 Qt API 时。
Qt6Widgets_VERSION 包含模块版本的字符串。

对于找到的所有包采用 find_package ,这些变量的等价物是可用的;它们区分大小写。

安装变量

此外,还有一些变量与特定包无关,但与 Qt 安装本身相关。

变量 描述

QT_DEFAULT_MAJOR_VERSION

控制 Qt 版本的整数, qt_ 命令被转发给 Qt 5 和 Qt 6 混合工程。需要将其设为 5 or 6 先前分别 find_package() 调用。

若设为 5 ,命令开头采用 qt_ 将调用的搭档的开头采用 qt5_ 。若设为 6 ,它们将调用的搭档的开头采用 qt6_ .

若未设置,首 find_package call defines the default version.

QT_LIBINFIX 保持库名称所用中缀的字符串,当有配置 Qt 采用 -libinfix .

QT_NO_CREATE_VERSIONLESS_FUNCTIONS

隐藏命令开头采用 qt_ ,只剩余版本号开头采用 qt6_ .

QT_NO_CREATE_VERSIONLESS_TARGETS

隐藏导入目标开头采用 Qt:: 。相反,需要使用的目标开头采用 Qt6:: .
QT_VISIBILITY_AVAILABLE 在 Unix,布尔描述 Qt 库和插件是否被编译采用 -fvisibility=hidden 。这意味着仅选中符号被导出。

工程变量

这些变量能影响由 QT 提供的 CMake 命令。它们可以由工程、工具链文件或其它第 3 方包设置。

Qt6::Core

ANDROID_NDK_HOST_SYSTEM_NAME

主机系统的特定 Android 体系结构

ANDROID_SDK_ROOT

Android SDK 的位置

QT_ANDROID_ABIS

List of ABIs that the project packages are built for

QT_ANDROID_APPLICATION_ARGUMENTS

传递给 Android 应用程序的自变量列表

QT_ANDROID_BUILD_ALL_ABIS

Enables building multi-ABI packages using the autodetected Qt for Android SDK list

QT_ANDROID_DEPLOY_RELEASE

Sets the package type as a release

QT_ANDROID_MULTI_ABI_FORWARD_VARS

Allows to share CMake variables in multi-ABI builds

QT_ANDROID_SIGN_AAB

Signs the .aab package with the specified keystore, alias, and store password

QT_ANDROID_SIGN_APK

Signs the package with the specified keystore, alias, and store password

QT_DEPLOY_BIN_DIR

Prefix-relative subdirectory for deploying runtime binaries on some target platforms

QT_DEPLOY_IGNORED_LIB_DIRS

Directories that are excluded from runtime dependencies search

QT_DEPLOY_LIB_DIR

Prefix-relative subdirectory for deploying libraries on some target platforms

QT_DEPLOY_PLUGINS_DIR

Prefix-relative subdirectory for deploying Qt plugins on some target platforms

QT_DEPLOY_PREFIX

用于部署的基位置

QT_DEPLOY_QML_DIR

用于在某些目标平台部署 QML 插件的前缀相对子目录

QT_DEPLOY_SUPPORT

用于设置部署支持的文件名称

QT_DEPLOY_TRANSLATIONS_DIR

Prefix-relative subdirectory for deploying Qt translations on some target platforms

QT_ENABLE_VERBOSE_DEPLOYMENT

启用部署工具的冗余模式

QT_HOST_PATH

主机 Qt 安装的位置,当交叉编译时

QT_IOS_LAUNCH_SCREEN

Path to iOS launch screen storyboard used by all targets

QT_NO_COLLECT_BUILD_TREE_APK_DEPS

Prevents collecting of project-built shared library targets during Android deployment

QT_NO_COLLECT_IMPORTED_TARGET_APK_DEPS

Prevents collecting of imported targets during Android deployment

QT_NO_SET_XCODE_BUNDLE_IDENTIFIER

在 iOS 目标完成期间禁用提供后备 APP 捆绑 ID

QT_NO_SET_XCODE_DEVELOPMENT_TEAM_ID

在 iOS 目标完成期间禁用提供后备团队 ID

QT_NO_STANDARD_PROJECT_SETUP

防止后续调用 qt_standard_project_setup() 做出任何改变

QT_PATH_ANDROID_ABI_<ABI>

Set of variables to specify the path to Qt for Android for the corresponding ABI

Qt6::Qml

QT_QML_OUTPUT_DIRECTORY

默认情况下将在其下创建 QML 模块的基输出目录

Qt6::InterfaceFramework

IFCODEGEN_VERBOSE

Enable verbose logging for all ifcodegen functions

QT_IFCODEGEN_TEMPLATE_SEARCH_PATH

Search path for ifcodegen templates

内容