CMake向安装目标添加depedency [英] CMake add depedency to the install target
问题描述
我有使用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):
pre>
add_dependencies为不存在的目标添加依赖关系:install
调用堆栈(最近调用):
CMakeLists.txt:141(include)
有可能得到一个简单的解决方法吗?因为如果目标没有连接,安装步骤不安装任何东西,除非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 theALL
option specified so it builds with theall
target.Then to install, it's just the
install
command. There is no need to add anything to theinstall
target.If you add the documentation to the
all
target, then doingmake install
will also build the documentation.这篇关于CMake向安装目标添加depedency的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!