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
qtp0003.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2024 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\page qt-cmake-policy-qtp0003.html
6
\ingroup qt-cmake-policies
7
\since 6.7
8
\title QTP0003
9
\keyword qt_cmake_policy_qtp0003
10
11
\summary {Consider the BUILD_SHARED_LIBS value when creating Qt libraries.}
12
13
This policy was introduced in Qt 6.7. The policy affects the default type of the
14
libraries created using \l {CMake Commands in Qt6 Core}{Qt CMake API}, like
15
\l {qt_add_library}, \l{qt_add_plugin}, \l{qt_add_qml_module}.
16
17
If the policy is set to \c OLD, the default library type that is selected is
18
aligned with the Qt build type, either \c shared or \c static.
19
20
If the policy is set to \c NEW, the library type is selected according to the
21
\l {CMake BUILD_SHARED_LIBS Documentation}{BUILD_SHARED_LIBS} value if it's set.
22
If \c BUILD_SHARED_LIBS is not set, the default library type falls back to the
23
Qt build type.
24
25
For example, the following code will use the Qt build type as the default
26
library type for the \c MyLib target, despite the fact \c BUILD_SHARED_LIBS is
27
set to \c ON:
28
\badcode
29
set(BUILD_SHARED_LIBS ON)
30
...
31
qt6_add_library(MyLib sourcefile.h sourcefile.cpp)
32
\endcode
33
34
If you set the QTP0003 to \c NEW before the \l {qt6_add_library}{qt_add_library}
35
call, \c BUILD_SHARED_LIBS will affect the library default type and \c MyLib
36
will be the shared library.
37
\badcode
38
set(BUILD_SHARED_LIBS ON)
39
...
40
qt_policy(SET QTP0003 NEW)
41
qt6_add_library(MyLib sourcefile.h sourcefile.cpp)
42
\endcode
43
44
\sa qt_policy, {Qt CMake policies}, qt_add_library
45
46
*/
qtbase
src
corelib
doc
src
cmake
policy
qtp0003.qdoc
Generated on
for Qt by
1.14.0