ADD_LIBRARY: Add a library to the project using the specified source files.
-
ADD_LIBRARY(libname [SHARED | STATIC | MODULE] [EXCLUDE_FROM_ALL]
source1 source2 ... sourceN)Adds a library target. SHARED, STATIC or MODULE keywords are used to set the library type. If the keyword MODULE appears, the library type is set to MH_BUNDLE on systems which use dyld. On systems without dyld, MODULE is treated like SHARED. If no keywords appear as the second argument, the type defaults to the current value of BUILD_SHARED_LIBS. If this variable is not set, the type defaults to STATIC.
If EXCLUDE_FROM_ALL is given the target will not be built by default. It will be built only if the user explicitly builds the target or another target that requires the target depends on it.
本文介绍了如何使用 CMake 的 ADD_LIBRARY 命令来添加一个库目标到项目中,并指定了源文件。可以根据需要设置库类型为 SHARED、STATIC 或 MODULE,默认情况下为 BUILD_SHARED_LIBS 的当前值,若未设置则默认为 STATIC。此外,还可以通过 EXCLUDE_FROM_ALL 选项控制该目标是否默认被构建。
280

被折叠的 条评论
为什么被折叠?



