Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qt_extract_metatypes.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2021 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\page qt-extract-metatypes.html
6
\ingroup cmake-commands-qtcore
7
8
\title qt_extract_metatypes
9
\keyword qt6_extract_metatypes
10
11
\summary {Extracts metatypes from a Qt target and generates an associated metatypes.json file.}
12
13
\include cmake-find-package-core.qdocinc
14
15
\cmakecommandsince 6.0
16
17
\section1 Synopsis
18
19
\badcode
20
qt_extract_metatypes(target
21
[MANUAL_MOC_JSON_FILES json_files...]
22
[OUTPUT_FILES variable_name]
23
)
24
\endcode
25
26
\versionlessCMakeCommandsNote qt6_extract_metatypes()
27
28
\section1 Description
29
30
Certain operations rely on metatype information being generated and collected
31
on targets. This is typically handled internally by Qt commands, but for
32
scenarios where this is not the case, \c{qt_extract_metatypes()} can be called
33
to force the collection of this information for a specific \c target.
34
35
Metatype information is generated for a target's source files in one of the
36
following ways:
37
38
\list
39
\li Automatically by AUTOMOC. The \c{qt_extract_metatypes()} command detects
40
when AUTOMOC is enabled on the \c target and will automatically extract the
41
information it needs.
42
\li Manually by invoking \c moc with the \c{--output-json} option. The project
43
is responsible for keeping track of all the JSON files generated using this
44
method and passing them to \c{qt_extract_metatypes()} with the
45
\c MANUAL_MOC_JSON_FILES option.
46
\endlist
47
48
\c{qt_extract_metatypes()} produces a target-specific metatypes JSON file which
49
collects all the metatype details from the AUTOMOC and manual moc inputs.
50
It does this by calling \c moc with the \c{--collect-json} option.
51
If you need to know where to find the resultant metatypes JSON file (for
52
example, to pass it to another command or to install it), use the
53
\c OUTPUT_FILES option to provide the name of a variable in which to store its
54
absolute path.
55
56
\section1 Automatic metatype extraction
57
58
Since Qt 6.8, if you have not disabled \c{AUTOMOC} and either are using CMake
59
3.19 or later or are calling \l{qt6_finalize_target}{qt_finalize_target()}
60
manually, then \c{qt_extract_metatypes()} is automatically called as part of the
61
finalization step for \l{qt_add_library}. This has no effect if you have
62
manually called \c{qt_extract_metatypes()} before the finalization, possibly
63
with custom arguments. However, it does make sure that the metatypes are also
64
produced if you haven't. This is important if any of the types in the library
65
are used as part of any QML types any time in the future and has no downsides.
66
67
Furthermore, \l{qt_add_qml_module} automatically invokes
68
\c{qt_extract_metatypes()} for its target.
69
70
*/
qtbase
src
corelib
doc
src
cmake
qt_extract_metatypes.qdoc
Generated on
for Qt by
1.16.1