如何使CMake重新配置取决于自定义文件? [英] How to make CMake reconfiguration depend on custom file?

查看:589
本文介绍了如何使CMake重新配置取决于自定义文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目下CMake与一些文件生成的python生成器从XML文件。我不能在CMakeLists.txt中指定这个生成器生成的所有文件,所以我使用文件globbing这个。



问题是,当我更新我的XML文件或生成器源这是在同一存储库)我想要我的构建系统重新配置,因此改变的文件时,重建代码(通过make例如)考虑到。



Is它可能使CMake处理一些文件,像它对待CMakeLists.txt文件,并使它重新生成构建系统时,这些文件更改?

解决方案

是的,你应该能够通过(ab)使用 configure_file()来实现。配置文件使源成为CMake运行的依赖项,因此任何更改都会导致重新配置。就像这样:

  configure_file(MyInputFile.xml DummyOutput.xml)
pre>

I have a project under CMake with some files generated with python generator from XML files. I cannot specify all files generated by this generator in CMakeLists.txt so I use file globbing for this.

The problem is that when I update my XML files or generator sources (which are in the same repository) I would like to have my build system reconfigured so changed files are taken into account when rebuilding the code (via make for example).

Is it possible to make CMake treat some files like it treats CMakeLists.txt files and to make it regenerate build system when those file are changed?

解决方案

Yes, you should be able to do that by (ab)using configure_file(). Configuring a file makes the source a dependency of the CMake run, so that any changes in it cause a reconfiguration. Simply like this:

configure_file(MyInputFile.xml DummyOutput.xml)

这篇关于如何使CMake重新配置取决于自定义文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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