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_add_plugin.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-add-plugin.html
6
\ingroup cmake-commands-qtcore
7
8
\title qt_add_plugin
9
\keyword qt6_add_plugin
10
11
\summary {Creates a Qt plugin target.}
12
13
\include cmake-find-package-core.qdocinc
14
15
\cmakecommandsince 6.0
16
17
\section1 Synopsis
18
19
\badcode
20
qt_add_plugin(target
21
[SHARED | STATIC]
22
[CLASS_NAME class_name]
23
[OUTPUT_TARGETS variable_name]
24
[MANUAL_FINALIZATION]
25
sources...
26
)
27
\endcode
28
29
The \c MANUAL_FINALIZATION option and the ability to set sources
30
were introduced in Qt 6.5.
31
32
\versionlessCMakeCommandsNote qt6_add_plugin()
33
34
\section1 Description
35
36
Qt plugin targets have additional requirements over and above an ordinary CMake
37
library target. The \c{qt_add_plugin()} command adds the necessary handling to
38
ensure these requirements are met. It should be called rather than the built-in
39
CMake \c{add_library()} command when defining a Qt plugin target.
40
41
By default, the plugin will be created as a \c STATIC library if Qt was built
42
statically, or as a \c MODULE library otherwise. You can override this default
43
by explicitly providing the \c STATIC or \c SHARED option.
44
45
Any \c{sources} provided will be passed through to the internal call to
46
\c{add_library()}.
47
48
\note Non-static plugins are meant to be loaded dynamically at runtime, not
49
linked to at build time. CMake differentiates between these two scenarios by
50
providing the \c MODULE library type for dynamically loaded libraries, and
51
the \c SHARED library type for libraries that may be linked to directly. This
52
distinction is important for some toolchains (notably Visual Studio), due to
53
the way symbol exports are handled. It may not be possible to link to
54
\c MODULE libraries, and generating a \c SHARED library with no exported
55
symbols can result in build-time errors. If the \c SHARED option is passed to
56
\c{qt_add_plugin()}, it will therefore create a \c MODULE library rather than a
57
\c SHARED library.
58
59
Every Qt plugin has a class name. By default, this will be the same as the
60
\c target, but it can be overridden with the \c CLASS_NAME option. The class
61
name corresponds to the name of the C++ class that declares the metadata for
62
the plugin. For static plugins, it is also the name passed to
63
\l Q_IMPORT_PLUGIN, which imports the plugin into an application and ensures it
64
is available at run time.
65
66
If the plugin is built statically, \c{qt_add_plugin()} may define additional
67
internal targets. These facilitate automatic importing of the plugin for any
68
executable or shared library that links to the plugin. If the project installs
69
the plugin and intends to make it available for other projects to link to, the
70
project should also install these internal targets. The names of these targets
71
can be obtained by providing the \c OUTPUT_TARGETS option, followed by the name
72
of a variable in which to return the target list.
73
74
\section2 Finalization
75
76
After a target is created, further processing or \e{finalization} steps may be
77
needed. The finalization processing is implemented by the
78
\l{qt6_finalize_target}{qt_finalize_target()} command.
79
80
For details and the meaning of the \c{MANUAL_FINALIZATION} option, refer to the
81
\l{qt_add_library finalization}{finalization documentation} for
82
\c{qt_add_library}.
83
84
\sa {qt6_finalize_target}{qt_finalize_target()},
85
{qt6_add_executable}{qt_add_executable()}
86
87
*/
qtbase
src
corelib
doc
src
cmake
qt_add_plugin.qdoc
Generated on
for Qt by
1.14.0