如何编写cmake安装库? [英] How to write cmake install for library?

查看:260
本文介绍了如何编写cmake安装库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是我的尝试

  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}处理它。



我可以做吗?

您可能想要 FILES 版本安装而不是 TARGETS 版本。



TARGETS 版本 install 用于实际的CMake目标, add_library 。在这种情况下,您可以通过在 add_library 命令中分配的名称而不是其完整路径来引用目标。



因此,在第二个命令中替换 TARGETS FILES 将是我想到的方式。 p>

有关 install 命令的详细信息,请运行:

  cmake --help命令install 


Here is my try

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()

both variants are wrong. what I want is to move libtinyscheme.so from ${tinyscheme-nix_BINARY_DIR} to /lib or /lib64, basically I think ${LIB_INSTALL_DIR} handles it.

So how can I make it? where is my mistake?

解决方案

You probably want the FILES version of install here instead of the TARGETS version.

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.

So replacing TARGETS with FILES in your second command would be the way to go here I think.

For full details on the install command, run:

cmake --help-command install

这篇关于如何编写cmake安装库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆