向CMake生成的构建系统本身添加依赖关系 [英] Add dependency to the CMake-generated build-system itself

查看:612
本文介绍了向CMake生成的构建系统本身添加依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

总之:我知道如何在CMake生成的构建系统中添加依赖关系到目标。

更长的问题:在CMake生成的构建过程

href =/ questions / tagged / cgalclass =post-tagtitle =显示问题标记为'cgal' =tag> cgal
,我们希望CMake自动重新运行配置步骤,当某些文件被修改时。不需要的细节在下面隐藏:


事实上,我们使用CMake生成CGAL库的构建系统/ examples / demos,同时也是我们的Doxygen生成文档的构建系统。 Doxyfile 是从多个文件生成的。


Makefile ,在 Makefile 中有一个特殊目标,名为 rebuild_cache ,但该目标(在Makefile级别)不是CMake目标。无论如何,我寻找一个跨平台的解决方案,也就是:可用于所有CMake发电机。我有一个印象,我想要的是还不能与CMake。

解决方案

自从CMake 3.0之后,您可以添加这样一个文件复制到目录属性 CMAKE_CONFIGURE_DEPENDS 。此属性包含文件列表;如果有任何更改,CMake将触发重新配置。






如果您使用CMake 2.x,属性 CMAKE_CONFIGURE_DEPENDS 不可用,但您可以使用以下技巧:



将文件传递到 configure_file(),即使你只是 COPYONLY 它们在某个位置,不使用生成的副本。 configure_file()正确地介绍了您正在寻找的构建系统依赖。





(注意:这个诀窍也是这个答案的原始内容,因为我不知道 CMAKE_CONFIGURE_DEPENDS )。


In short: I know how to add dependencies to targets, in a CMake-generated build system. But I would like to add dependencies to the generated build-system itself.

Longer question: In the CMake-generated build process of , we would like CMake to automatically re-run the configuration step, when certain files are modified. Unneeded details are hidden below:

As a matter of fact, we generate using CMake the build system for the CGAL libraries/examples/demos, but also at the same time the build system for our Doxygen-generated documentation. The Doxyfile is generated from multiple files.

When the CMake generator is "Makefile", there is a special target in the Makefile, that is named rebuild_cache, but that target (at the Makefile level) is not a CMake-target. And anyway, I look for a solution that is cross-platform, that is: usable with all CMake generators. I have the impression that what I want is not yet doable with CMake. Can you please confirm, so that I can fill a documented feature-request?

解决方案

Since CMake 3.0, you can add such a file to the directory property CMAKE_CONFIGURE_DEPENDS. This property holds a list of files; if any of them changes, CMake will trigger re-configuration.


If you're using CMake 2.x, the property CMAKE_CONFIGURE_DEPENDS is not available, but you can use the following trick:

Pass the files through configure_file(), even if you just COPYONLY them someplace and don't use the resulting copies. configure_file() introduces precisely the buildsystem dependency you're looking for.

This works, but it adds the overhead of copying the file.

(Note: This trick was also the original content of this answer, since I was not aware of CMAKE_CONFIGURE_DEPENDS at time of answering).

这篇关于向CMake生成的构建系统本身添加依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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