如何为库编写CMake安装? [英] How do I write CMake install for a library?
问题描述
这是我的尝试:
IF (NOT WIN32)
#INSTALL_TARGETS(${LIB_INSTALL_DIR} ${tinyscheme-nix_BINARY_DIR}/libtinyscheme.so)
#INSTALL(TARGETS ${tinyscheme-nix_BINARY_DIR}/libtinyscheme.so DESTINATION ${LIB_INSTALL_DIR})
ENDIF()
两个变体都是错误的.我想将libtinyscheme.so
从${tinyscheme-nix_BINARY_DIR}
移到/lib
或/lib64
.基本上,我认为${LIB_INSTALL_DIR}
会处理它.
Both variants are wrong. I want to move libtinyscheme.so
from ${tinyscheme-nix_BINARY_DIR}
to /lib
or /lib64
. Basically, I think ${LIB_INSTALL_DIR}
handles it.
我该怎么做?我的错误在哪里?
How can I make it? Where is my mistake?
推荐答案
您可能希望此处使用install
的FILES
版本而不是TARGETS
版本.
You probably want the FILES
version of install
here instead of the TARGETS
version.
install
的TARGETS
版本用于实际的CMake目标,这些目标已使用例如add_library
.在这种情况下,您将通过在add_library
命令期间分配的目标名称而不是其完整路径来引用目标.
The TARGETS
version of install
is used for actual CMake targets which have been added using e.g. add_library
. In this case, you would refer to the target by its name assigned during the add_library
command, rather than its full path.
所以我认为在您的第二个命令中用FILES
替换TARGETS
将会是这里的方法.
So replacing TARGETS
with FILES
in your second command would be the way to go here I think.
有关install
命令的完整详细信息,请运行:
For full details on the install
command, run:
cmake --help-command install
这篇关于如何为库编写CMake安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!