Skip to content
Snippets Groups Projects
api.md 11.3 KiB
Newer Older
Alexandru Croitor's avatar
Alexandru Croitor committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
# New public API

A bunch of new CMake public API functions or renamed functions from `qt5_` to `qt6_`.

<br>

# qtbase

https://github.com/qt/qtbase/blob/dev/src/corelib/Qt6CoreMacros.cmake

<br>


`qt6_make_output_file` - marked deprecated in qt5, should be internal?

<br>


`qt6_get_moc_flags` - marked deprecated in qt5, should be internal?

<br>


`qt6_create_moc_command` - marked deprecated in qt5, should be internal?

<br>


`qt6_generate_moc` - renamed from qt5_, has versionless

<br>



`add_qt_gui_executable` - maybe rename to `add_qt_executable`, or `qt_add_executable`?
```cmake
function(add_qt_gui_executable target)
        add_executable("${target}" WIN32 MACOSX_BUNDLE ${ARGN})
        add_library("${target}" MODULE ${ARGN}) # android
        target_link_libraries("${target}" PRIVATE Qt::Core)
        if(TARGET Qt::Gui)
            target_link_libraries("${target}" PRIVATE Qt::Gui)
        endif()
endfunction()
```

<br>


`qt6_generate_meta_types_json_file` - new, has versionless
```cmake
# Generate Qt metatypes.json for a target.
#
#  INSTALL_DIR: Location where to install the metatypes file. For public consumption defaults to a ${CMAKE_INSTALL_PREFIX}/lib/metatypes directory.
#
#  COPY_OVER_INSTALL: (Qt Internal) When present will install the file via a post build step copy rather than using install.
#
#   MANUAL_MOC_JSON_FILES: list of manually generated json files
function(qt6_generate_meta_types_json_file target)

```

<br>


`qt6_generate_win32_rc_file` - new, has versionless
```cmake
# Generate Win32 RC files for a target.
# All entries in the RC file are generated
# from target properties:
# QT_TARGET_COMPANY_NAME, QT_TARGET_DESCRIPTION, etc.
# The QT_TARGET_WINDOWS_RC_FILE prop can be used to specify a custom RC file instead of autogenerating one
function(qt6_generate_win32_rc_file target)

```



<br>

`qt6_add_plugin` - new, has versionless

```cmake
# Build a Qt plugin.
# No installation behavior.
# Might be missing some implementation details that are handled by the internal counterpart.
# Arguments:
# STATIC: Make it a static plugin
# OUTPUT_NAME: name of the plugin file
# CLASS_NAME
# TYPE: imageformats, etc
function(qt6_add_plugin target)
```

<br>


`qt6_disable_utf8_sources` - new, has versionless

```cmake
# By default Qt6 forces usage of utf8 sources for consumers of Qt.
# Users can opt out of utf8 sources by calling this function with the target name of their application or library.
function(qt6_disable_utf8_sources target)
```

<br>


`qt6_add_resources` - old, has versionless, new `TARGET` behavior instead of outfiles var.

```cmake
# When using this command with static libraries, one or more special targets
# will be generated. Should you wish to perform additional processing on these targets pass a value to the OUTPUT_TARGETS parameter.
function(qt6_add_resources outfiles )
    if (TARGET ${outfiles})
```

<br>


https://github.com/qt/qtbase/blob/dev/src/corelib/Qt6AndroidMacros.cmake

`qt6_android_generate_deployment_settings` - new, has versionless, should be internal?

```cmake
# Generate the deployment settings json file for a cmake target.
# Uses global vars
#    ANDROID_NDK
#    ANDROID_SDK_ROOT
#    ANDROID_NDK_HOST_SYSTEM_NAME
#    CMAKE_ANDROID_ARCH_ABI
#    QT_ANDROID_APPLICATION_ARGUMENTS
#    QT_HOST_PATH
#    CMAKE_SYSROOT
# Uses target properties:
#   QT_ANDROID_DEPLOYMENT_DEPENDENCIES
#   QT_ANDROID_EXTRA_PLUGINS
#   QT_ANDROID_EXTRA_LIBS
#   QT_ANDROID_PACKAGE_SOURCE_DIR
#   QT_QML_IMPORT_PATH
#   QT_QML_ROOT_PATH
# Sets target property:
#   QT_ANDROID_DEPLOYMENT_SETTINGS_FILE
#
function(qt6_android_generate_deployment_settings target)
```

<br>


`qt6_android_apply_arch_suffix` - new, has versionless, should be internal?

```cmake
function(qt6_android_apply_arch_suffix target)
    get_target_property(target_type ${target} TYPE)
    if (target_type STREQUAL "SHARED_LIBRARY" OR target_type STREQUAL "MODULE_LIBRARY")
        set_property(TARGET "${target}" PROPERTY SUFFIX "_${CMAKE_ANDROID_ARCH_ABI}.so")
    endif()
endfunction()
```

<br>


`qt6_android_add_apk_target` - new, has versionless, should be internal?

```cmake
# Add custom target to package the APK
# Uses global vars:
#    QT_HOST_PATH
#    CMAKE_ANDROID_ARCH_ABI
#    QT_NO_GLOBAL_APK_TARGET - allow opt out of global target add_dependencies
# Uses target properties:
#   QT_ANDROID_DEPLOYMENT_SETTINGS_FILE
function(qt6_android_add_apk_target target)
```

<br>


`qt6_android_get_sdk_build_tools_revision` - new, has versionless, should be internal?

```cmake
# Locate newest Android sdk build tools revision
# Uses global vars:
#   ANDROID_SDK_ROOT
function(qt6_android_get_sdk_build_tools_revision out_var)
```


# qtdeclarative


https://github.com/qt/qtdeclarative/blob/dev/src/qml/Qt6QmlMacros.cmake

`qt6_import_qml_plugins` - old, has versionless

```cmake
# For static builds only.
# Calls qmlimportscanner, links in used qml plugins, generates and compiles a cpp file with relevant Q_IMPORT_PLUGIN() macro calls.
#
# Arguments:
# PATH_TO_SCAN: Path to pass to qmlimportscanner to scan .qml files for the modules they use.

function(qt6_import_qml_plugins target)
```

<br>


`qt6_add_qml_module` - new, has versionless

```cmake
# Creates a QML module.
# Arguments:
# URI: Declares the module identifier of the module (REQUIRED)

# VERSION: The module's version. (REQUIRED)

# TARGET_PATH: Overwrite the generated target path. (OPTIONAL)

# RESOURCE_PREFIX: Resource Prefix to be used when generating a static library. (OPTIONAL)

# OUTPUT_DIRECTORY: If the module is not to be built under ${CMAKE_CURRENT_BINARY_DIR}. This ensures the qmldir file is copied to the right location. (OPTIONAL)

# INSTALL_LOCATION: Intended installation directory for this module. Default installation path will be ${INSTALL_QMLDIR}. (OPTIONAL).

# DO_NOT_INSTALL_METADATA: Will not install supporting files.

# INSTALL_QML_FILES: Will install the qml files along side the plugin.

# SOURCES: List of C++ sources. (OPTIONAL)

# DEPENDENCIES: List of QML Module dependencies and their versions. The module and its version must be separated via a slash(/). E.g. QtQuick/2.0

# QML_FILES: List of Qml files.

# CLASSNAME: Provides the class name of the C++ plugin used by the module. (REQUIRED for static targets)

# DESIGNER_SUPPORTED: Specify this argument if the plugin is supported by Qt Designer (OPTIONAL)

# TYPEINFO: Path to a file which declares a type description file for the module that can be read by QML tools such as Qt Creator to access information about the types defined by the module's plugins. (OPTIONAL)

# IMPORTS: List of other Qml Modules that this module imports. (OPTIONAL)

# OPTIONAL_IMPORTS: List of other Qml Modules that this module may import at
# run-time. Those are not automatically imported by the QML engine when
# importing the current module, but rather serve as hints to tools like
# qmllint. (OPTIONAL)

# RESOURCE_EXPORT: In static builds, processed QML files are compiled into a static lib, this names the target.

# SKIP_TYPE_REGISTRATION: When present will cause the generated qmldir file
# to not list any qml types. These are expected to be registered by the
# c++ plugin code instead.

# PLUGIN_OPTIONAL: The plugin is marked as optional in the qmldir file.

function(qt6_add_qml_module target)
```



`qt6_target_qml_files` - new, has versionless

```cmake
# Add Qml files (.qml,.js,.mjs) to a Qml module. This will also append the
# qml files to the qmldir file of the module. Source file properties can
# be used to control the generated qmldir entry.

# QT_QML_SOURCE_VERSION: Version(s) for this qml file.

# QT_QML_SOURCE_TYPENAME: Override the file's type name.

# QT_QML_SINGLETON_TYPE: The qml file contains a singleton type.

# QT_QML_INTERNAL_TYPE: When set to true, the type specified by

# QT_QML_SOURCE_TYPENAME will not be available to users of this module.

# QT_QML_SKIP_QMLDIR_ENTRY: No qmldir entry will be created for the source file. Useful if a file needs to be installed (like a private JS file) but does not expose a public type.

function(qt6_target_qml_files target)
```

<br>


`qt6_qml_type_registration` - new, has versionless, should be internal?

```cmake
# Creates a .qmltypes file and compiles an auto-generated "${target}_qmltyperegistrations.cpp" file.

# Target properties used:
# QT_QMLTYPES_FILENAME: Used for the name of the generated file.
# QT_QML_MODULE_URI: Module URI of target
# QT_QML_MODULE_VERSION: Module version
# QT_QML_MODULE_INSTALL_DIR: Install location for .qmltypes file
# QT_QML_MODULE_INSTALL_QMLTYPES: Whether to install the .qmltypes file

# Sets properties:
# QT_QML_MODULE_PLUGIN_TYPES_FILE - path to the generated .qmltypes file

function(qt6_qml_type_registration target)
```


# qtquick3d



https://github.com/qt/qtquick3d/blob/dev/src/quick3d/Qt6Quick3DMacros.cmake

`qt6_quick3d_build_shaders` - new, has versionless

```cmake
# Generates shaders from the given files and links the compiled resource files into ${target}.
#
# Arguments used:
# resource_name: creates .qrc file based on value of the argument
# FILES: list of shader file paths

function(qt6_quick3d_build_shaders target resource_name)
```


# qtshadertools


https://github.com/qt/qtshadertools/blob/dev/src/shadertools/Qt6ShaderToolsMacros.cmake

`qt6_add_shaders` - new, has versionless

```cmake
# Invokes qsb on each file in FILES. Extensions must be .vert, .frag, or .comp.
# The resulting .qsb files are added as resources under PREFIX.
# target and resourcename are like for qt6_add_resources.
# Uses qt6_add_resources.
#
# Arguments used:
#
#  FILES: list of file paths, e.g.  color.vert

#  DEFINES: list of custom macros for glslang

#  PREFIX: Qt resource prefix to use, e.g  "/shaders"
#
#  BATCHABLE: enable generating batchable vertex shader variants

#  PRECOMPILE: invoke native tools where applicable

#  PERTARGETCOMPILE: compile to SPIR-V and translate separately per output language version

#  NOGLSL:  skip generating the language
#  NOHLSL:  skip generating the language
#  NOMSL: skip generating the language

#  DEBUGINFO: generate full debug
#  OPTIMIZED: optimize for performance

#  GLSL: override the version to generate
#  HLSL: override the version to generate
#  MSL: override the version to generate

function(qt6_add_shaders target resourcename)
```



# qtremoteobjects

https://github.com/qt/qtremoteobjects/blob/dev/src/remoteobjects/Qt5RemoteObjectsMacros.cmake
https://github.com/qt/qtremoteobjects/blob/dev/src/remoteobjects/Qt6RemoteObjectsMacros.cmake


All the functions below seem to implement what `qt5_generate_repc` does, but with completely new names and arguments. `qt5_generate_repc` is not ported to `qt6_` atm.

<br>

`qt6_add_repc_files` - new, no versionless yet

```cmake
# Calls `repc` on list of FILES and adds them as `target` sources.
#
# Arguments:
# type: one of 'source', 'replica', 'merged'
# FILES: list of files to call repc on
function(qt6_add_repc_files type target)
```

<br>

`qt6_add_repc_source` - new, no versionless yet

Calls `qt6_add_repc_files` with `type` set to `source`.


<br>

`qt6_add_repc_replica` - new, no versionless yet

Calls `qt6_add_repc_files` with `type` set to `replica`.

<br>


`qt6_add_repc_merged` - new, no versionless yet

Calls `qt6_add_repc_files` with `type` set to `merged`.

<br>


`qt6_rep_from_header` - new, no versionless yet

```cmake
# Creates a .rep interface file from a QObject header
#
# Arguments:
# ${ARGN}: list of files to run `repc -o rep` on.
function(qt6_rep_from_header target)
```