Qt for HarmonyOS CMake API

Note: The HarmonyOS CMake API is in technology preview and may change in future releases.

This page lists the CMake commands, target properties, and variables that configure how a Qt application is packaged into a HarmonyOS Ability Package (HAP).

When you create a Qt executable with qt_add_executable() while targeting HarmonyOS, Qt automatically generates a <target>_make_hap build target that produces the HAP. The commands, properties, and variables below control the contents of that HAP and the metadata written into the HarmonyOS manifest files.

A HarmonyOS application bundle is described by two kinds of manifest: the application-level app.json5, which holds metadata that applies to the whole bundle, and the module-level module.json5, which describes a single HAP module within that bundle. The target properties below mirror this split: the QT_HARMONYOS_APP_* properties set application-level metadata, such as the vendor, version, label, and icon, while properties such as QT_HARMONYOS_MODULE_DESCRIPTION and QT_HARMONYOS_ABILITY_ORIENTATION set module-level metadata. See the Target Properties section below for the full list.

Commands

Target Properties

The following target properties affect how the HAP is built:

QT_HARMONYOS_ABILITY_ORIENTATION

The screen-orientation policy of the HarmonyOS ability.

QT_HARMONYOS_APP_BUNDLE_NAME

The HarmonyOS application's bundle name.

QT_HARMONYOS_APP_ICON

The HarmonyOS application's icon.

QT_HARMONYOS_APP_LABEL

The HarmonyOS application's label.

QT_HARMONYOS_APP_NAME

The HarmonyOS application's name.

QT_HARMONYOS_APP_VENDOR

The HarmonyOS application's vendor.

QT_HARMONYOS_APP_VERSION_CODE

The HarmonyOS application's version code.

QT_HARMONYOS_APP_VERSION_NAME

The HarmonyOS application's version name.

QT_HARMONYOS_COMPATIBLE_SDK_VERSION

The HarmonyOS application's compatible SDK version.

QT_HARMONYOS_COMPILE_SDK_VERSION

The HarmonyOS application's compile SDK version.

QT_HARMONYOS_EXTRA_LIBS

Extra libraries to deploy with the HarmonyOS target.

QT_HARMONYOS_EXTRA_PLUGINS

Extra Qt plugins to deploy with the HarmonyOS target.

QT_HARMONYOS_MODULE_DESCRIPTION

The HarmonyOS module's description.

QT_HARMONYOS_MODULE_DEVICE_TYPES

The device types supported by the HarmonyOS module.

QT_HARMONYOS_PACKAGE_SOURCE_DIR

Path to a custom HarmonyOS package template.

QT_HARMONYOS_TARGET_ARCHS

The target architectures of the HarmonyOS application.

QT_HARMONYOS_TARGET_SDK_VERSION

The HarmonyOS application's target SDK version.

Variables

The following variables affect how the HAP is built: