CMake向安装目标添加depedency [英] CMake add depedency to the install target

查看:698
本文介绍了CMake向安装目标添加depedency的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用cmake的以下问题。我使用 http://tobias.rautenkranz.ch/cmake/doxygen/ 中的UseDoxygen生成我的库的文档。这工作正常,但知道我想实现以下:
当我调用make install我想构建文档和安装它。因此,我添加

  install(DIRECTORY $ {DOXYFILE_OUTPUT_DIR} / $ {DOXYFILE_HTML_DIR} DESTINATION share / doc / mylib /)
add_dependencies(install doc)

到我的CMakeLists.txt。
这将导致错误:

  CMakeModules / UseDoxygen.cmake的CMake错误:145(add_dependencies):
add_dependencies为不存在的目标添加依赖关系:install
调用堆栈(最近调用):
CMakeLists.txt:141(include)
pre>

有可能得到一个简单的解决方法吗?因为如果目标没有连接,安装步骤不安装任何东西,除非make doc是手动执行的,因为调用make install。



关于
Grisu

解决方案

通过添加 add_custom_target 并指定 ALL 选项,所以它使用 all target。



然后安装,它只是 install 命令。不需要向 install 目标中添加任何内容。



如果您将文档添加到 all 目标,则执行 make install 也将构建文档。


I've got the following problem using cmake. I use UseDoxygen from http://tobias.rautenkranz.ch/cmake/doxygen/ to generate the documentation for my library. This works fine, but know I want to realize the following: When I call "make install" I want to build to Documentation and install it too. Therefore I add

install(DIRECTORY ${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_HTML_DIR} DESTINATION share/doc/mylib/)
add_dependencies(install doc) 

to my CMakeLists.txt. This results in an error:

  CMake Error at CMakeModules/UseDoxygen.cmake:145 (add_dependencies):
  add_dependencies Adding dependency to non-existent target: install
Call Stack (most recent call first):
  CMakeLists.txt:141 (include)

Is it possible to get a easy workaround for this? Because if the targets are not connected the install step installs nothing unless "make doc" is done manually befor calling "make install".

regards Grisu

解决方案

We build our documentation by adding it with add_custom_target with the ALL option specified so it builds with the all target.

Then to install, it's just the install command. There is no need to add anything to the install target.

If you add the documentation to the all target, then doing make install will also build the documentation.

这篇关于CMake向安装目标添加depedency的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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