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_DEPLOYMENT_TYPE

Forces or disables release package signing regardless of the build type

QT_ANDROID_GENERATE_JAVA_QTQUICKVIEW_CONTENTS

Enables the generation of QtQuickViewContent-based classes

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_LIBEXEC_DIR

Prefix-relative subdirectory for deploying program executables on some target platforms

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_I18N_SOURCE_LANGUAGE

Specifies the language of translatable strings

QT_I18N_TRANSLATED_LANGUAGES

List of languages to be used for project internationalization

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

QT_USE_TARGET_ANDROID_BUILD_DIR

Enables the use of per-target Android build directories

Qt6::InterfaceFramework

IFCODEGEN_VERBOSE

Enable verbose logging for all ifcodegen functions

QT_IFCODEGEN_TEMPLATE_SEARCH_PATH

Search path for ifcodegen templates

Qt6::Multimedia

QT_NO_FFMPEG_XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY

Disables FFmpeg code-signing on iOS

Qt6::Qml

QT_QML_GENERATE_AOTSTATS

Controls whether QML Compiler statistics collection is enabled

QT_QML_GENERATE_QMLLS_INI

Enables autogeneration of .qmlls.ini files for QML Language Server

QT_QML_GENERATE_QMLLS_INI_NO_CMAKE_CALLS

Customizes the value of no-cmake-calls in .qmlls.ini files for QML Language Server

QT_QML_NO_CACHEGEN

Disables compilation of QML files into bytecode or C++ code

QT_QML_OUTPUT_DIRECTORY

默認情況下將在其下創建 QML 模塊的基輸齣目錄

Standard CMake Variables

CMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG Improves the dependency graph for multi-configuration generators