创建并定稿库。
命令的定义在
Core
组件对于
Qt6
package. Load the package with:
find_package(Qt6 COMPONENTS Core REQUIRED)
qt_add_library(target [STATIC | SHARED | MODULE | INTERFACE | OBJECT] [MANUAL_FINALIZATION] sources... )
若
无版本命令
被禁用,使用
qt6_add_library()
代替。它支持如此命令的一组相同自变量。
qt_add_library()
is a wrapper around CMake's built-in
add_library()
command. It performs the following tasks:
The type of library created can be specified explicitly with one of the
STATIC
,
SHARED
,
MODULE
,
INTERFACE
or
OBJECT
keywords, just as one might for
add_library()
. If none of these keywords are given, the library type created depends on how Qt was built. If Qt was built statically, a static library will be created. Otherwise, a shared library will be created. Note that this is different to how CMake's
add_library()
command works, where the
BUILD_SHARED_LIBS
variable controls the type of library created. The
qt_add_library()
command does not consider
BUILD_SHARED_LIBS
when deciding the library type.
任何
sources
provided will be passed through to the internal call to
add_library()
.
After a target is created, further processing or finalization steps may be needed. The finalization processing is implemented by the qt_finalize_target() 命令。
Finalization can occur either as part of this call or be deferred to sometime after this command returns (but it should still be in the same directory scope). When using CMake 3.19 or later, finalization is automatically deferred to the end of the current directory scope. This gives the caller an opportunity to modify properties of the created target before it is finalized. When using CMake versions earlier than 3.19, automatic deferral isn't supported. In that case, finalization is performed immediately before this command returns.
Regardless of the CMake version, the
MANUAL_FINALIZATION
keyword can be given to indicate that you will explicitly call
qt_finalize_target()
yourself instead at some later time. In general,
MANUAL_FINALIZATION
should not be needed unless the project has to support CMake 3.18 or earlier.
另请参阅 qt_finalize_target () 和 qt_add_executable ().